UISegmentedControl 的 TintColor 没有反应
来吧!
我几乎一天都在看这个!
我想设置 UISegmentedControl 的色调颜色,但它没有反应...
NSArray *segControlItems = [NSArray arrayWithObjects:
@"L",
@"H",
@"A",
nil];
UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];
segControl.frame = CGRectMake(0, 0, 90, 30);
segControl.segmentedControlStyle = UISegmentedControlStyleBar;
segControl.momentary = YES;
segControl.tintColor = [UIColor greenColor];
[segControl addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *segBarItem = [[UIBarButtonItem alloc] initWithCustomView:segControl];
self.switchView.navigationItem.rightBarButtonItem = segBarItem;
[segControl release];
[segBarItem release];
苹果是否制作了一些像“makeUISegmentedControlsDontSetAnyTintColor”这样的属性? 请帮助...
单个按钮有效: http://img257.imageshack.us/i/ schermafbeelding2010102.png/
但是分段后就搞砸了:http://img714。 imageshack.us/i/schemafbeelding2010102.png/
Come oon!
I am almost looking a day at this!
I want to set my tint color of my UISegmentedControl but it doesnt react...
NSArray *segControlItems = [NSArray arrayWithObjects:
@"L",
@"H",
@"A",
nil];
UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];
segControl.frame = CGRectMake(0, 0, 90, 30);
segControl.segmentedControlStyle = UISegmentedControlStyleBar;
segControl.momentary = YES;
segControl.tintColor = [UIColor greenColor];
[segControl addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *segBarItem = [[UIBarButtonItem alloc] initWithCustomView:segControl];
self.switchView.navigationItem.rightBarButtonItem = segBarItem;
[segControl release];
[segBarItem release];
Has apple made some property like "makeUISegmentedControlsDontSetAnyTintColor" ore soo?
Please help...
A single button works: http://img257.imageshack.us/i/schermafbeelding2010102.png/
But with the segmented it's messed up: http://img714.imageshack.us/i/schermafbeelding2010102.png/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用 InterfaceBuilder 毫无问题地完成了它。我有三个部分,一些带有标签,一些带有标签+图片,一切正常。
一定是您转换为 BarButtonItem 不起作用。您可以尝试将分段控件添加为导航栏的子视图,而不是将其诱骗到按钮中。
I've done it without problems using InterfaceBuilder. I had three segments, some with labels, some with labels + pictures, all working fine.
It must be your conversion into a BarButtonItem that doesn't work. You could try adding the segmented control as a subview of the nav bar instead of coaxing it into a button.
这是一个非常古老的问题,但我今天遇到了这个问题(Xcode 7b5/iOS 9)。就我而言,segmentedControl 是导航栏中的 UIBarButtonItem。我可以通过等待下一个运行循环来设置tintColor,如下所示:
This is a really old question but I ran into this problem today (Xcode 7b5/iOS 9). In my case the segmentedControl was a UIBarButtonItem in the navBar. I was able to set the tintColor by waiting for the next run loop, like so: