4

I'm having a very odd problem with tint color in iOS7.

When the ViewController that I'm having trouble with first loads, all of the tint is a light gray color, as if everything is inactive or behind a UIAlertView that has dimmed the screen. The buttons are still active and work just fine, but they are all gray. (I have the tint color set to orange, more on that in a bit).

Here's the odd part. If I present, and then immediately dismiss another ViewController, all of the orange tint appears and everything works as expected. That is the only way I have been able to get the tint to appear - nothing else seems to work.

I'm using the same basic code patterns throughout the app, and this problem really only affects one ViewController. This particular ViewController is presented UIModalPresentationFullScreen, and UIModalTransitionStyleCoverVertical, if those matter at all.

Here's how I'm setting tinting:

First, I have set a tint color on each view controller within interface builder, these settings are the same across both working and problematic VCs.

Next, I have set a tint color globally in my App Delegate like this:

    [_window setTintColor:[UIColor orangeColor]];

The above two work on most of my ViewControllers, but not on all of them for some reason. For the ones that it was not working on, I've been using a handful of different techniques to get the tint color to work. For example:

self.view.tintColor = [UIColor orangeColor];

or

[_myUIBarButtonItem setTitleTextAttributes:
 [NSDictionary dictionaryWithObject:[UIColor orangeColor]
                             forKey:NSForegroundColorAttributeName]
                                           forState:UIControlStateNormal];

or to force a tintColor update:

[_myButtonOutlet setTitleColor:_cancelButtonOutlet.tintColor
                      forState:UIControlStateNormal];

Any ideas?

itnAAnti
  • 652
  • 8
  • 17
  • where/when do you assign tintColor to the view, in viewDidLoad or just appDelegate ? – Yohst Jan 12 '14 at 06:25
  • Currently, in both. I've had it in appDelegate since the beginning, and I also added it to viewDidLoad on the VC in question when I realized that the appDelegate code was not working on this particular VC. – itnAAnti Jan 12 '14 at 15:03
  • 1
    Take a look at this: http://stackoverflow.com/questions/19026351/ios-7-uirefreshcontrol-tintcolor-not-working-for-beginrefreshing It seems that applying tintColor isn't always straight forward. Have you implemented tintColorDidChange ? See apple docs: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/AppearanceCustomization.html – Yohst Jan 13 '14 at 15:20
  • I looked through the links that you provided. I had previously gone through that Apple doc, but I did so more carefully this time - to no avail. – itnAAnti Jan 14 '14 at 01:12
  • I did some more testing and I have more details to add that may be helpful. First, the views that I am having difficulty with are sub-views. I'm using `self.view addSubview:` to add the views, after the main view is loaded and showing. I used some NSLog statements to dump out the tint color of some of the elements that I'm having difficulty with. They do have the orange tint color set -- it's just not showing. I've read that tint color should be set offscreen, so I'm wondering if my sub-views are not picking up the tint color because they're loaded after the main view has been displayed. – itnAAnti Jan 14 '14 at 01:20
  • At some point between `viewDidLoad` and `viewDidAppear` the tint color gets set to `UIDeviceWhiteColorSpace 0.595 0.8`. – itnAAnti Jan 14 '14 at 01:31
  • [This](http://stackoverflow.com/questions/19244991/ios-7-modal-view-makes-buttons-grey-disabled) thread has a similar issue - but I cannot explicitly update tint color on the whole window, no matter what I set or where, it retains the old `UIDeviceWhiteColorSpace` color. – itnAAnti Jan 14 '14 at 01:47

1 Answers1

4

In iOS7, there are different tint behaviors you can choose from depending on what you want.

All you need to do is adjust the window's tintAdjustmentMode property to Normal in didFinishLaunching in app delegate.

self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
Alex Nguyen
  • 2,820
  • 1
  • 19
  • 14