objective c - Set Text Colour of Placeholder Text of UITextfield Apple TV -
how set text colour of placeholder text of uitextfield in both normal , focused state.
i using code setting placeholder text colour
self.emailtextfield.attributedplaceholder = [[nsattributedstring alloc] initwithstring:@"email address" attributes:@{nsfontattributename:[uifont fontwithname:@"opensans" size:24], nsforegroundcolorattributename:[uicolor whitecolor]}]; self.passwordtextfield.attributedplaceholder = [[nsattributedstring alloc] initwithstring:@"password" attributes:@{nsfontattributename:[uifont fontwithname:@"opensans" size:24], nsforegroundcolorattributename:[uicolor whitecolor]}];
default focus go email textfield. email textfield placeholder colour black.
if focus goes password text field, placeholder text colour of email textfield still black colour.
you can set nsattributedstring
placeholder so:
self.totextfield.attributedplaceholder = [[nsattributedstring alloc] initwithstring:@"placeholdertext" attributes:@{nsforegroundcolorattributename: [uicolor redcolor]}];
you can change color, font family, size etc.. of placeholder using nsattributedstring
.
Comments
Post a Comment