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

Popular posts from this blog

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -