The effect you want to achieve:
//
Viewcontroller.m
A14- textview with placeholders
//
Created by Vic fan on 16/6/24.
copyright©2016 year Li Hongqiang . All rights reserved.
//
#import "ViewController.h"
@interface Viewcontroller () <uitextviewdelegate>
@property(nonatomic,strong)UILabel *label1;
@property(nonatomic,weak)Uitextview *textview1;
@end
@implementation Viewcontroller
-(void) viewdidload {
[Super viewdidload];
additional setup after loading the view, typically from a nib.
self. View. BackgroundColor = [uicolor whitecolor];
uitextview *textview = [[uitextview alloc] init];
self. TextView1 = TextView;
self. TextView1. Font = [uifont systemfontofsize:];
self.< Span class= "S9" >textview1. Frame =cgrectmake (20 Span class= "S11" >50,[uiscreen mainscreen< Span class= "S1" >. bounds. Size. Width-50100
self. TextView1. Autoresizingmask = Uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth;
self. TextView1. Layer. BorderColor = [uicolor blackcolor]. Cgcolor;
self. TextView1. Layer. Maskstobounds = YES;
self. TextView1. Layer. BorderWidth = 1;
self. TextView1. BackgroundColor = [uicolor whitecolor];
[self. View addsubview:self. TextView1];
self. TextView1. Hidden = NO;
self. TextView1. Delegate = self;
/// second Uitextview above the uilable,uilable set to global variables.
UILabel *label1 = [[UILabel alloc]init];
self. Label1 = Label1;
self.< Span class= "S9" >label1. Frame =cgrectmake (27 Span class= "S11" >17uiscreen mainscreen< Span class= "S1" >. bounds. Size. Width-50100
self. Label1. Text = @ " please input your valuable comments , suggestions , we will continue to improve ";
self. Label1. Enabled = NO; Lable must be set to not available
self. Label1. BackgroundColor = [uicolor clearcolor];
self. Label1. Font = [uifont systemfontofsize:];
[self. View addsubview:self. Label1];
}
// implement Uitextview 's agent
-(void) Textviewdidchange: (uitextview *) textView
{
self. TextView1. Text = TextView. Text;
if (TextView. Text. Length = = 0) {
self. Label1. Text = @ " please input your valuable comments , suggestions , we will continue to improve ";
}Else{
self. Label1. Text = @ "";
}
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
//Dispose of any resources, can be recreated.
}
@end
Customizing the placeholder and borders of TextView