Wednesday, 23 May 2012

Change Customize UITextfield placeholder text in XCode

HI
to change the color of UITextfield placeholder text there are three approaches
[Click here to join best group of zeaous iOS developer on FACEBOOK]
  1. Override the drawPlaceholderInRect:(CGRect)rect 
 - (void) drawPlaceholderInRect:(CGRect)rect {
    [[UIColor <your color>] setFill];
    [[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:10]];
   }
2.Access the private iVar(risky apple might not approve)
[self.password setValue:[UIColor colorWithRed:(160/255) green:(97/255) blue:(5/255) alpha:1]forKeyPath:@"_placeholderLabel.textColor"];

3.Its not a way but a trick put a ui label in the appropriate place and hide it in
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    switch (textField.tag) {
        case 0:
            lblUserName.hidden=YES;
            break;
        case 1:
            lblPassword.hidden=YES;
            break;
            
        default:
            break;
    }
    
}
[Join Like Minded and helpful group of iOS developers on FACEBOOK]

No comments:

Post a Comment