1

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.enter image description here

SURESH SANKE
  • 1,653
  • 17
  • 34

3 Answers3

2
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

Community
  • 1
  • 1
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
1

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.

Mateusz
  • 314
  • 1
  • 5
1

enter image description here

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

Ankish Jain
  • 11,305
  • 5
  • 36
  • 34