UISegmentedControl 选定的色调未显示
当我将整个导航栏设置为黑色时,通常在所选按钮的 UISegmentedControl 上显示的色调不会显示(self.navigationController.navigationBar.tintColor = [UIColor blackColor];< /代码>)。
这是一个错误还是我遗漏了什么?
The tint that usually shows on a UISegmentedControl
on the selected button isn't showing when I set the whole nav bar to black (self.navigationController.navigationBar.tintColor = [UIColor blackColor];
).
Is this a bug or something I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
为了显示色调颜色,有几个要求:
tintColor
必须工作。您还提到您已将
tintColor
设置为[UIColor blackColor]
。不幸的是,UISegmentedControl
将始终以较深颜色显示所选段,而不是较亮的颜色。尝试将tintColor
设置为[UIColor darkGrayColor]
,您应该能够看到所选片段的颜色发生变化。In order for the tint color to show, there are a couple of requirements:
It's required for the
tintColor
to work.You also mention that you have the
tintColor
set to[UIColor blackColor]
. Unfortunately, theUISegmentedControl
will always display the selected segment with a darker color, never a lighter. Try setting yourtintColor
to[UIColor darkGrayColor]
and you should be able to see the selected segment change color.您是否尝试过单独设置分段控件的色调?
Have you tried setting the tint on the segmented control separately?
尝试使用色调
[UIColor colorWithWhite:80.0/255.0 alpha:1.0]
。这使得黑色变得不那么黑,并且允许选择的片段在选择后变得更暗。您可以根据需要设置白色分量。
示例代码:
Try using tint color
[UIColor colorWithWhite:80.0/255.0 alpha:1.0]
.This makes the black color less black and allows the selected segment to become darker after selection. You can set the white component as suitable.
Sample code:
在 iPhone 3.0 上,如果您想在 NavigationController 中添加分段控件,请先执行此操作,然后在执行此操作后更改色调颜色。
On iphone 3.0, if you want add the Segmented Control in a NavigationController, do that first and change the tintcolor after u did that.
如果您在导航栏上看到不同的色调,您可能还需要使用 uisegmentedcontrol 上的瞬时属性。
segmentedControl.momentary=YES;
这会清除控件的突出显示色调。
If you are seeing different tint colors on the nav bar, you may also want to use the momentary property on your uisegmentedcontrol.
segmentedControl.momentary=YES;
This clears the highlight tint from the control.
在属性检查器中将分段控件样式更改为条形或边框。就这样。
Change the segmented control style to Bar or Bezeled in the Attributes Inspector. That's all.