sridevi
sridevi

Reputation: 627

How to set images to a UISearchBar's scope bar items?

For the UISearchBar's scopebar I want to set images instead of titles to identify different scopes. I found only scopeButtonTitles method to set titles in the UISearchBar class reference. Is there a way to set images for the scopes?

Upvotes: 2

Views: 624

Answers (1)

ing.conti
ing.conti

Reputation: 145

Very simple:

// use Appearance proxy:
id temp = [UISegmentedControl appearanceWhenContainedIn:[UISearchBar class], nil];

UIImage * img = [UIImage imageNamed:@"my_img1"];
[temp setImage:img forSegmentAtIndex: 0];

img = [UIImage imageNamed:@"my_img2"];
[temp setImage:img forSegmentAtIndex: 1];

.....

Upvotes: 1

Related Questions