简体   繁体   English

如何在 Xcode 界面构建器中更改默认色调颜色?

[英]How to change default tint color in Xcode interface builder?

How does one change the global default tint color in Xcode interface builder?如何更改 Xcode 界面构建器中的全局默认色调颜色?

在此处输入图片说明

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. 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]]; Obj-C: [[[[UIApplication sharedApplication] delegate] window] setTintColor:[UIColor orangeColor]];

Swift: UIWindow(frame: UIScreen.mainScreen().bounds).tintColor = 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除非您在链中更改它,即在 UIViewController 中

viewDidLoad:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用xcode 5界面构建器设置选项卡栏色调(背景)颜色 - using xcode 5 interface builder for setting tab bar tint (background) color 当在 Xcode 11, beta 2 的 Interface Builder 中指定条形着色颜色时,UITabBarItem 图标的颜色对于 iOS 13 不正确 - UITabBarItem icon not colored correctly for iOS 13 when a bar tint color is specified in Interface Builder in Xcode 11, beta 2 如何在 Xcode 中设置 XIB 文件的默认色调颜色? - How to set default tint color for XIB files in Xcode? 如何更改 UIAlertController 的色调颜色? - How to change tint color of UIAlertController? 如何更改 UIDatePicker 色调颜色? - How to change UIDatePicker tint color? 如何在界面生成器 (Xcode 9) 中工作的 UIButton 子类中设置默认标题 - How to set a default title in UIButton subclass that works in Interface Builder (Xcode 9) 如何在xcode 6.3界面构建器情节提要中默认模拟指标? - How to default simulated metrics in xcode 6.3 interface builder storyboard? 如何在Xcode中设置pdf资产的色调? - How to set tint color on pdf asset in Xcode? 如何在 XCode 4 Interface Builder 中将 window 方向更改为横向? - How can I change a window orientation to landscape in XCode 4 Interface Builder? Xcode 6 Interface Builder-颜色选择器是否奇怪/错误? - Xcode 6 Interface Builder - color picker oddity/bug?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM