如何在 Xcode 界面构建器中更改默认色调颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31795512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change default tint color in Xcode interface builder?
提问by mindbomb
回答by Marco Boschi
回答by joe g
Interface Builder Way: Select the Storyboard or Xib file you want to set the default tint on.
Interface Builder Way:选择要设置默认色调的 Storyboard 或 Xib 文件。
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.
然后在第一个选项卡 File Inspector 的 Utilities 中查找 Interface Builder Document 部分,您将看到如下图所示的 Global Tint。
(not enough reputation to post images)
(没有足够的声誉来发布图片)
Programmatically:
以编程方式:
Obj-C:[[[[UIApplication sharedApplication] delegate] window] setTintColor:[UIColor orangeColor]];
对象-C:[[[[UIApplication sharedApplication] delegate] window] setTintColor:[UIColor orangeColor]];
Swift:UIWindow(frame: UIScreen.mainScreen().bounds).tintColor = UIColor.orangeColor()
迅速:UIWindow(frame: UIScreen.mainScreen().bounds).tintColor = UIColor.orangeColor()
回答by justdan0227
This does not appear to work if you turn on localization. The Global Tint dissapears
如果您打开本地化,这似乎不起作用。全局色调消失
回答by Vitaliy Gozhenko
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
}
回答by Adrian Sluyters
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 i.e. in UIViewController's
只有它会应用广泛。除非你在链中改变它,即在 UIViewController 中
viewDidLoad: