简体   繁体   English

非条形样式分段控件上的色调颜色

[英]Tint color on non-bar style segmented control

I've got a compilation issue with a UiSegmentedControl, whose style is bezeled. 我有一个UiSegmentedControl的编译问题,它的样式是bezeled。 The colour is black. 颜色是黑色。 I get an error: 我收到一个错误:

"Tint color on non-bar style segmented control"

Can this be solved, and is it an issue for app submission? 这可以解决,这是应用程序提交的问题吗?

I think that's a bug in Xcode/Interface Builder. 我认为这是Xcode / Interface Builder中的一个错误。
The iOS HIG say nothing about the different styles and the documentation explicitly allows tint colors for bezeled UISegmentedControls: iOS HIG没有说明不同的样式,文档明确允许为bezeled UISegmentedControls设置色彩:

UISegmentedControlStyleBezeled UISegmentedControlStyleBezeled
Segmented controls in this style can have a tint color. 此样式的分段控件可以具有色调。

I would just ignore the warning. 我会忽略这个警告。

In the interface builder, select the Segment control. 在界面构建器中,选择“段”控件。

In the Attribute inspector, Set the Tint to Default . 在“属性”检查器中,将“ 色调”设置为“ 默认”

For some reason, the XIB spouts this warning, but iOS indeed supports a tintColor with a bezeled style. 出于某种原因,XIB会发出此警告,但iOS确实支持带有bezeled样式的tintColor。 You can avoid the warning by specifying it programmatically. 您可以通过以编程方式指定它来避免警告。 There's a trick, though. 但是有一个技巧。 If the style is set to bezeled, setting the tintColor will be ignored. 如果样式设置为bezeled,则将忽略设置tintColor。 You need to do it like this: 你需要这样做:

[segControl setSegmentedControlStyle:UISegmentedControlStyleBar];
segControl.tintColor = [UIColor colorWithWhite:0.48 alpha:1.0];
[segControl setSegmentedControlStyle:UISegmentedControlStyleBezeled];

In this case, I'm loading a XIB that has it set to bezeled (so I can see how it fits)...but I set it back to a bar and change the tint before setting it back. 在这种情况下,我正在加载一个设置为bezeled的XIB(所以我可以看到它是如何适合的)...但我将它设置回一个条并在设置之前更改色调。 Weird. 奇怪的。

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

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