开发者

UITextField Keep the placeholder text on while focused

开发者 https://www.devze.com 2023-02-21 07:52 出处:网络
I want to keep the place holder text shown while it i开发者_运维百科s focused (that is, while it is the first responder). It should stay that way only until something is typed and the field no longer

I want to keep the place holder text shown while it i开发者_运维百科s focused (that is, while it is the first responder). It should stay that way only until something is typed and the field no longer blank.

Address Book app's Search bar behaves like this, as do the new contact entry fields.

Is there any way to do that?


I don't think this comes "built in" for you to activate it, but you can build it rather easily on your own: Create a UILabel you want to display and when the focus is set onto the TextField place the UILabel at the right spot (slightly after the cursor).

As soon as the user enters a character you hide the UILabel. You can see when the user starts the edit and starts to type by adding your class as delegate to the UISearchBar (see callbacks "searchBar:textDidChange:" and "searchBarTextDidBeginEditing:"): http://bit.ly/eQlvRz

0

精彩评论

暂无评论...
验证码 换一张
取 消