UISegmentedControl 触摸时的色调颜色
我的应用程序中有一个 UISegmentedControl (请参阅下面的代码):
// --------------- SETTING NAVIGATION BAR RIGHT BUTTONS
NSArray *segControlItems = [NSArray arrayWithObjects:[UIImage imageNamed:@"up.png"],[UIImage imageNamed:@"down.png"], nil];
segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];
segControl.segmentedControlStyle = UISegmentedControlStyleBar;
segControl.momentary = YES;
segControl.frame = CGRectMake(25.0, 7, 65.0, 30.0);
segControl.tintColor = [UIColor blackColor];
[segControl addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
if (current == 0) [segControl setEnabled:NO forSegmentAtIndex:0];
if (current == ([news count]-1)) [segControl setEnabled:NO forSegmentAtIndex:1];
// ---------------
但是当您单击它时我无法让它显示某些内容...
它功能正常,但我希望当您单击它时它会变成灰色(但当你点击时)...这可能吗?
谢谢你,
戈泰。
I have a UISegmentedControl in my app (see code below) :
// --------------- SETTING NAVIGATION BAR RIGHT BUTTONS
NSArray *segControlItems = [NSArray arrayWithObjects:[UIImage imageNamed:@"up.png"],[UIImage imageNamed:@"down.png"], nil];
segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];
segControl.segmentedControlStyle = UISegmentedControlStyleBar;
segControl.momentary = YES;
segControl.frame = CGRectMake(25.0, 7, 65.0, 30.0);
segControl.tintColor = [UIColor blackColor];
[segControl addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
if (current == 0) [segControl setEnabled:NO forSegmentAtIndex:0];
if (current == ([news count]-1)) [segControl setEnabled:NO forSegmentAtIndex:1];
// ---------------
But I can't make it to show something when you click on it ...
It functionnally works perfectly but I would like it to tint to gray when you click on it (but just when you click) ... would that be possible ?
Thank you,
Gotye.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
似乎所选片段的色调颜色比原始色调更深。因此,如果您的色调为黑色,则所选片段的色调颜色不会改变,因为没有比这更暗的颜色了。
我环顾四周,没有找到任何好的方法来控制此控件的所选片段的色调颜色。
Seems as if the selected segment's tint color is made darker than original tint. Therefore if your tint is black then the selected segment's tint color doesn't change since there isn't anything darker than that.
I've looked around and haven't found any nice way to control the selected segment's tint color for this control.
创建自己的分段控件的配方,(我猜)可以根据需要进行配置:
idevrecipes 自定义分段控件
顺便说一句:一个非常非常有趣的网站!
A recipe to create own segmented controls, which (I guess) can be configured as you want:
idevrecipes custom segmented control
BTW: A very very interesting website!
试试这个。如果您使用片段标题,它可以工作,如果您使用图像,您可能需要修改它。
Try this. It works if you use segment titles, you may need to modify it if you use images.