While using uisearchbar with scope bar the tint color of scope bar is not updating in iOS 4.3.In remaining iOS versions it is working perfectly.I have shown the screenshot of that sample here.Any ideas to solve this please.

- 1,653
- 17
- 34
-
1How are you tinting it? Programatically, or in IB? I'd suggest posting the code you're using, if possible – lxt Jan 02 '13 at 11:17
-
through IB i have done that – SURESH SANKE Jan 02 '13 at 11:24
-
@SURESHSANKE just search the subview of searchbar, in which UISeagmentControl and then change the color of this, this is scopebar of searchbar – Paras Joshi Jan 02 '13 at 11:53
3 Answers
for (id subview in yourSearchDisplayController.searchBar.subviews )
{
if([subview isMemberOfClass:[UISegmentedControl class]])
{
UISegmentedControl *scopeBar=(UISegmentedControl *) subview;
[scopeBar setSegmentedControlStyle:UISegmentedControlStyleBar];
[scopeBar setTintColor: [UIColor redColor]];//you can also set RGB color here
//scopeBar.tintColor = [UIColor blackColor];
}
}
Also see my answer from this link for modify the UISearchBar
component
How to change inside background color of UISearchBar component on iOS

- 1
- 1

- 20,427
- 11
- 57
- 70
-
Even i tried with this code it didn't work for me.iOS 4.3 it is unable to change the tint color of scope bar. – SURESH SANKE Jan 02 '13 at 12:17
-
@SURESHSANKE hi dude not i change my simulator from 5.1 to 4.3 and its display the differ color i set reedcolor and its display in redcolor dude – Paras Joshi Jan 02 '13 at 12:30
-
1Ya it is working josh thank U.I forgot to set the style then it didn't work.Thank u . – SURESH SANKE Jan 02 '13 at 12:46
If I remember correctly, it was not possible to change a tint of the scope bar. One solution could be to search all the subviews of the search bar and find the scope bar object and try to modify its background. But this might lead you to modifying private property so it might not be acceptable. I was trying going this way but I abandoned it, not sure why.
Other not so clean solution would be to implement the scope bar by yourself and add it as a subview to the search bar and block the original scope bar. Do this only for the iOS 4.3 or less.

- 314
- 1
- 5
Change the tint color for changing color of scope bar. Note BarTintColor is different - this will change the color of the search bar.

- 11,305
- 5
- 36
- 34