Is there a way I can get the global tint color from my project by code? To avoid a misunderstanding I mean the global tint color, which i can set in the File Inspector.
相关问题
- @objc protocol crashes the swift compiler
- Getting UITableViewCell from its superview iOS 7 i
- Access paging in iOS - previous and next : retriev
- Install Ad Hoc distributed app on iOS via USB, usi
- UITableViewCell top shadow is covered by UITableVi
相关文章
- didBeginContact:(SKPhysicsContact *)contact not in
- ios7 new pan gesture to go back in navigation stac
- IOS UICollectionview Dynamically change Cell's
- PhoneGap iOS 7 and localStorage
- Add UITextField to title view of navigation item
- iOS7 crashing - [__NSPlaceholderDictionary initWit
- SKStoreProductViewController rate disabled on iOS
- Chrono Timer Not Converting Seconds Properly
Swift 4.x:
Usage:
Max's answer is correct, but I found out that you have to get the navigationController's window:
However, note that this wouldn't work if you have set the tintColor manually from Storyboard. The value from Storyboard will be used if you have done so. I've filed a bug with Apple on this. I think this code shouldn't be ignored even if we've set the tintColor from Storyboard.
Easy.
Objective C:
Swift:
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.
Seems to work.
In the app delegate you can set it by