Get global tint color from code

Easy.

Objective C:

UIColor *tintColor = [[self view]tintColor];

Swift:

let tintColor = self.view.tintColor;

This should get the tintColor set on the app. If you change it, this property should get updated. This assumes you’re inside a viewController or a subclass of one and that you haven’t overridden the tintColor in some superView between this view and the window.

Update: Notice if you are attempting to get the tint color of a view controller that has not been added to the window then it will not have the custom tint color since this color is inherited from the window object. Thanx to @ManuelWa for pointing this out in the comments.

Leave a Comment

tech