Change Default Global Tint Color in Swift

Change global tint color - iOS7/iOS8

Simply change the UIWindow 's tintColor in your application delegate, it's automatically passed as default to all its UIView descendants.

[self.window setTintColor:[UIColor greenColor]];

Change default global tint color in swift

This answer was last revised for Swift 5.2 and iOS 13.5 SDK.


You can set the tintColor on your window. Because tint color cascades down to all subviews (unless explicitly overridden), setting it on a window will effectively make it global inside that window.

Add the following line to your application(_:didFinishLaunchingWithOptions:) or scene(_:willConnectTo:options:) just before making the window key and visible:

window.tintColor = .systemOrange /* or .orange on iOS < 13 */

You can also set in in the storyboard by changing the Global Tint property:

Sample Image

How to change default tint color in Xcode interface builder?

In the File inspector tab of the Utility panel, the right one, you can find controls about size classes, auto layout and the global tint of your storyboard.

Sample Image

Change global tint color programmatically DURING RUNTIME iOS8, Swift

Set the window's tintColor in code in response to the user's desire. The change will propagate down the whole interface immediately.

How can I change the global tint color programmatically?

Change the tint color of the UIWindow of the application. You can either use the [[UIApplication sharedApplication] keyWindow] but better is to use [[UIApplication sharedApplication] delegate].window.

Change global tint per target

I found a solution to my problem. Here is a step by step guide:

TLDR:
Don't change the tint color, change the image rendering mode.

Define tint colors
Add file called Constants-TargetName.swift for each target and add it to the buid settings of the corresponding target. Inside that file goes the definition for the global tint color (and other global constants for that target if needed).

let kTintColor = UIColor(red: 0.0, green: 0.0, blue: 170.0/255.0, alpha: 1.0)

Set global tint color
Change the global tint color in AppDelegate.swift, inside application(didFinishLaunchingWithOptions):

UIView.appearance().tintColor = kTintColor

Change the color of a UIBarButtonItem
Set your image to have the color you want to change it to. I my case, I have a blue global tint color and the images are gray. So the code below switches colors between gray and blue.
Instead of changing the tint color for a single UIBarButtonItem, change its image:

if globalTintColor {
self.btn.image = UIImage(named: "ImgName")?.imageWithRenderingMode(.AlwaysTemplate)
} else {
self.btn.image = UIImage(named: "ImgName")?.imageWithRenderingMode(.AlwaysOriginal)
}

Eureka Forms: How to change form global tint colour

Updated Eureka 4.3.x

You should override a variable customNavigationAccessoryView in your controller

override var customNavigationAccessoryView: (UIView & NavigationAccessory)? {
// The width might not be correctly defined yet: (Normally you can use UIScreen.main.bounds)
let navView = NavigationAccessoryView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0))
navView.barTintColor = UIColor.MaterialColors.category3
navView.tintColor = UIColor.white
return navView
}

Here you go and fix the colour of Done Label.
override NaviagtionAccessoryView Instance as navigationAccessoryView below

navigationAccessoryView.tintColor = "Your Colour"
navigationAccessoryView.backgroundColor = "Your Colour"
navigationAccessoryView.doneButton.tintColor = "Your Colour"

More Here

Eureka Forms: How to change form global tint colour

Updated Eureka 4.3.x

You should override a variable customNavigationAccessoryView in your controller

override var customNavigationAccessoryView: (UIView & NavigationAccessory)? {
// The width might not be correctly defined yet: (Normally you can use UIScreen.main.bounds)
let navView = NavigationAccessoryView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0))
navView.barTintColor = UIColor.MaterialColors.category3
navView.tintColor = UIColor.white
return navView
}

Here you go and fix the colour of Done Label.
override NaviagtionAccessoryView Instance as navigationAccessoryView below

navigationAccessoryView.tintColor = "Your Colour"
navigationAccessoryView.backgroundColor = "Your Colour"
navigationAccessoryView.doneButton.tintColor = "Your Colour"

More Here



Related Topics



Leave a reply



Submit