Anhelme
Anhelme

Reputation: 11

How can I change color in UITextField when editing

I have UITextField with grey text "username", while this field aren't selecting by user . How can I change color to black, when user select this field and will begin type his username? Sry my English

Upvotes: 0

Views: 659

Answers (3)

Ahmed Hammad
Ahmed Hammad

Reputation: 445

Just set the placeHolder text as "username" and it will be displayed in grey color then set the textColor of your textField as black color so when you will begin editing you will edit with blackcolor

Upvotes: 0

Pedro Vieira
Pedro Vieira

Reputation: 3370

I think you're approaching it the wrong way. From what I read i think that you need to go with "placeholder" text.
Open your xcode project, go to your .xib or .storyboard file, click on your UITextField and input 'username' on the Placeholder textfield, like the following image:
enter image description here


The placeholder text is a gray text that is displayed when your UITextField is empty.

Upvotes: 2

Eugene
Eugene

Reputation: 10045

Use the placeholder property of UITextField for the grayed text that will be replaced with whatever user types in.

Upvotes: 0

Related Questions