Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set placeholder text in uitextview

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.24k
    Comment on it

    If we want to set the placehoder text in uitextview then we have to use the delegates methods of textview because there is not an option to set the placeholder directly in xcode.

    Here is the methods--

    -

     (void)viewDidLoad {
       [super viewDidLoad];
       textView.textColor = [UIColor lightGrayColor];
       [textView setText:@"Placeholder text"];
    }
    
    -(void)textViewDidBeginEditing:(UITextView *)textView {
        if([textView.text isEqualToString:@"Placeholder text"]){
            textView.textColor = [UIColor blackColor];
            textView.text=nil;
        }
    }
    
    -(void)textViewDidEndEditing:(UITextView *)textView {
        if([textView.text isEqual:@""]){
            textView.textColor = [UIColor lightGrayColor];
            [textView setText:@"Placeholder text"];
        }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: