Xcode 中的色调是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35950489/
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
What is tint in Xcode?
提问by TimSim
Really basic question that I can't find the answer to. What is tint in Xcode and why is the default tint for all views blue? What does it affect? I've noticed that colors of some images within these views don't look quite right unless I set the tint to white and it's really annoying to have to set every new view's tint to white just because I don't understand what it does.
非常基本的问题,我找不到答案。什么是 Xcode 中的色调,为什么所有视图的默认色调都是蓝色?它有什么影响?我注意到这些视图中某些图像的颜色看起来不太正确,除非我将色调设置为白色,而且不得不将每个新视图的色调设置为白色真的很烦人,因为我不明白它的作用。
采纳答案by willrichman
This articlehas a great explanation and run through of it, but to sum up, tint is an easy way to highlight interactive elements with a color of your choice.
这篇文章有一个很好的解释并贯穿了它,但总而言之,色调是一种用您选择的颜色突出显示交互元素的简单方法。
It is also used in conjunction with UIImage to color an image with its renderingMode
property set to UIImageRenderingModeAlwaysTemplate
or (in certain cases like images in tab bars) UIImageRenderingModeAutomatic
. My guess is that this is what you are running into when certain images change their color to blue, which is the default application tintColor
.
它还与 UIImage 结合使用,以将其renderingMode
属性设置为UIImageRenderingModeAlwaysTemplate
或(在某些情况下,例如标签栏中的图像)为图像着色UIImageRenderingModeAutomatic
。我的猜测是,当某些图像将颜色更改为蓝色(这是默认应用程序)时,您会遇到这种情况tintColor
。
回答by bhavik shah
Tint color is a "default" or "fallback" color for the application or UIView. As Apple states, "it is the first non-default color in the heirarchy. All subclasses of UIView derive their behavior for tintColor from the base class.". So if you add a new view controller to your project and its tint color is Blue, then when you add a button to this view, the title text of this button is also blue. This is because the button's tintcolor will be inherited from the main view (whose tint color is blue). Changing the tint color of the main view will change the title color of its subviews too.
色调颜色是应用程序或 UIView的“默认”或“后备”颜色。正如 Apple 所说,“它是层次结构中的第一个非默认颜色。UIView 的所有子类都从基类派生了它们的 tintColor 行为。”。所以如果你在你的项目中添加一个新的视图控制器并且它的色调是蓝色,那么当你向这个视图添加一个按钮时,这个按钮的标题文本也是蓝色的。这是因为按钮的色调将从主视图(其色调颜色为蓝色)继承。更改主视图的色调颜色也会更改其子视图的标题颜色。
回答by James
Tint is the default colour for textfields, labels etc. The Tint doesn't effect anything, it just changes the colour of certain properties (e.g. textfields, and labels etc. to blue / red / green etc.) Unfortunately you will have to continue to keep changing the tint as annoying as it is, due to it being a default colour from the Xcode program. Hope this helps :)
Tint 是文本字段、标签等的默认颜色。Tint 不会产生任何影响,它只是将某些属性(例如文本字段和标签等)的颜色更改为蓝色/红色/绿色等。不幸的是,您将不得不继续继续改变色调,因为它是 Xcode 程序的默认颜色。希望这可以帮助 :)
回答by Sheamus
From the UIView
API in iOS 9, it looks like the tintColor
is intended as something that is generic, provided as a general convenience property to be used wherever you like on the view:
从UIView
iOS 9 中的API来看,它看起来像是tintColor
通用的东西,作为通用的便利属性提供,可以在视图上的任何地方使用:
If the system cannot find a nondefault color in the hierarchy, this property's value is a system-defined color instead.
如果系统在层次结构中找不到非默认颜色,则此属性的值将改为系统定义的颜色。
From Xcode 6 Release Notes:
来自 Xcode 6 发行说明:
Objective-C APIs can now express the nullability of properties whose setters allow nil (to “reset” the value to some default) but whose getters never produce nil (because they provide some default instead) using the null_resettable property attribute. One such property is tintColor in UIView, which substitutes a default system tint color when no tint color has been specified.
Objective-C API 现在可以使用 null_resettable 属性来表达属性的可空性,这些属性的 setter 允许 nil(将值“重置”为某个默认值)但其 getter 从不产生 nil(因为它们提供了一些默认值)。一个这样的属性是 UIView 中的 tintColor,当没有指定色调颜色时,它会替换默认的系统色调颜色。