UPDATE ANSWER. Via ME.
There are currently problems with changing the text color of my UISegmentedControl ; it must be changed on first boot using UIControlStateSelected . The code works, but only conditionally. It works when you visit a page using the segmented control in the navigation bar, click the back button, and then go back to the page. I assume that there is a problem with inheritance. Let me explain ..
The location of the segmented control is on top of my navigation bar.
Inheritance of the ViewController that contains the SegmentedControl: TabBarViewController (controlled by AppDelegate) -> Navigation controller -> ViewController (where `inviteSegBar 'is located)
Here is the code in AppDelegate.m:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"#669900"]];
And here is the viewDidLoad: code viewDidLoad: for a VC that contains "inviteSegBar", the UISegmentedControl in question:
- (void)viewDidLoad { [super viewDidLoad]; //CUSTOM APPEARANCE <below> self.navigationController.navigationBar.barTintColor = [UIColor whiteColor]; self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"#669900"]; inviteSegBar.tintColor = [UIColor colorWithHexString:@"#333333"]; [[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#669900"]} forState:UIControlStateSelected]; }
As I said, the last line works, but only when you go to the page. Why is this happening?
PS These are the same problems, I already tried this code before any of the answers was specified.
ios objective-c uicolor uisegmentedcontrol
Chisx Jan 16 '14 at 8:05 2014-01-16 08:05
source share