Illep
Illep

Reputation: 16851

How to add a text to UISearchBar programmatically

I have added a UISearchBar. In that i need to type a text saying hello World. But It should be like a placeholder text, similar to this;

In the searchBar in the image, you will see the text Search displayed. instead of Search i want to mention hello world.

I tried ;

searchBar.text=@"hello World";

but this will simply add a text and not a placeholder text as shown in the image.

Upvotes: 2

Views: 692

Answers (1)

Tobi Weißhaar
Tobi Weißhaar

Reputation: 1677

try using

searchBar.placeholder = @"hello world";

Upvotes: 5

Related Questions