简体   繁体   中英

How to change default tint color in Xcode interface builder?

How does one change the global 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.

在此处输入图片说明

Interface Builder Way : Select the Storyboard or Xib file you want to set the default tint on.

Then in Utilities on the first tab File Inspector look for the Interface Builder Document section and you will see a Global Tint like the image below shows.

(not enough reputation to post images)

在此处输入图片说明

Programmatically :

Obj-C: [[[[UIApplication sharedApplication] delegate] window] setTintColor:[UIColor orangeColor]];

Swift: UIWindow(frame: UIScreen.mainScreen().bounds).tintColor = UIColor.orangeColor()

You can set default tint color for whole window:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.tintColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1)
        return true
}

This does not appear to work if you turn on localization. The Global Tint dissapears

You can set the default appearance settings with:

UIButton.appearance().tintColor = UIColor.orangeColor()

If you place it in:

application:didFinishLaunchingWithOptions:

and only it'll apply application wide. Unless you change it lower down in the chain ie in UIViewController's

viewDidLoad:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM