tommy
tommy

Reputation: 302

How to change the default text in Search Bar in IOS?

HI I develop an application in IOS and I meet a problem that I want to change the default text which is "search" in search bar to "Key in video title to search". How to do it ? Please help me Thank you. enter image description here

Upvotes: 2

Views: 4071

Answers (3)

Sam Fischer
Sam Fischer

Reputation: 1472

The UISearchBar and the UITextField have this property of a placeholder which is the default text in the fields.

1.Change it from the Interface Builder. Interface Builder

2.Change it through code

self.searchBarObject.placeholder = @"Key In Video Title To Search";

Read what Apple has written about the UISearchField.

Upvotes: 9

manujmv
manujmv

Reputation: 6445

You can set the placeholder property

sBar.placeholder = @"Key in video title to search";

Upvotes: 2

Undo
Undo

Reputation: 25697

You can use the plain old placeholder property:

mySearchBar.placeholder = @"Foo!";

Relevant documentation.

It can also be changed within Interface Builder:

enter image description here

Upvotes: 2

Related Questions