开发者

Tint color on non-bar style segmented control

开发者 https://www.devze.com 2023-04-12 22:42 出处:网络
I\'ve got a compilation issue with a UiSegmentedControl, whose style is bezeled. The colour is black. I get an error:

I've got a compilation issue with a UiSegmentedControl, whose style is bezeled. The colour is black. I get an error:

"Tint color o开发者_如何学JAVAn 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.
The iOS HIG say nothing about the different styles and the documentation explicitly allows tint colors for bezeled UISegmentedControls:

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. 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. 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. Weird.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号