0
votes

I'm encountering a very weird problem which is driving me crazy.

The problem is that sometimes (it doesn't always happen), after showing a popup, the bar buttons and any UISegmentedControl become red, while they should be white (see the pictures below).

Here is also the code (in the app delegate initialization method) with which I set the the tint color of my app:

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIColor redColor], NSForegroundColorAttributeName,
                                                       shadow,NSShadowAttributeName,
                                                       [UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
                                                       NSFontAttributeName,
                                                       nil]];

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor redColor], NSForegroundColorAttributeName,
                                                      shadow,NSShadowAttributeName,
                                                      [UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
                                                      NSFontAttributeName,
                                                      nil] forState:UIControlStateNormal];

if ([self.window respondsToSelector:@selector(setTintColor:)])
    self.window.tintColor = [UIColor redColor];

[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];

[[UITabBar appearance] setTintColor:[UIColor redColor]];

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];

Any idea of why this is happening? I think that if there was a problem in my code, navigation bar buttons and segmented controls would be red since the app was launched, not after a while. What do you guys think?

Thanks

enter image description here

enter image description here

2

2 Answers

0
votes

Mind trying setting de background color to white? It seems to be this that is changed. If this corrects it then we have a starting point

 [[UITabBar appearance] setBackgroundColor:[UIColor whiteColor];

try and reply.

0
votes

The problem is gone after commenting the following two lines:

if ([self.window respondsToSelector:@selector(setTintColor:)])
self.window.tintColor = [UIColor redColor];