尝试执行以下操作:
[self setSelectedSegmentTintColor:tintColor];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}
forState:UIControlStateSelected];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}
forState:UIControlStateSelected|UIControlStateHighlighted];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: tintColor}
forState:UIControlStateNormal];
但是看来我无法forState:UIControlStateSelected|UIControlStateHighlighted
。这是我的标签的外观:
哪个还可以。但是当我按下所选项目时,文本颜色变为白色(淡色):
是否可以为所选和突出显示的文本配置颜色?