UISearchBAR scopeBar tintColor

后端 未结 8 2112
小蘑菇
小蘑菇 2021-02-02 15:46

Has anyone managed to color the scopebar portion of a UISearchBar, it has a tintColor property but setting it does not affect the attached scopebar UISegmentedControl. Ive got a

8条回答
  •  忘掉有多难
    2021-02-02 16:35

    Here's some copy paste friendly code for what the others are discussing.

    scopeBar.segmentedControlStyle = UISegmentedControlStyleBar; //required for color change
    for (id subview in self.searchDisplayController.searchBar.subviews )
    {
        if([subview isMemberOfClass:[UISegmentedControl class]])
        {
            UISegmentedControl *scopeBar=(UISegmentedControl *) subview;
            scopeBar.tintColor =  [UIColor blackColor];         
        }
    }
    

    If you a white box like area around your buttons, you can change the color of that through interface builder.

    I wouldn't say it looks "like ass" as the others do, but it isn't really ideal either.

提交回复
热议问题