我使用它来更改分段控件文本的文本颜色,但其颜色在UIControlStateNormal
中没有更改。我必须为这两个州保持相同的颜色。
NSDictionary *highlightedAttributes = [NSDictionary
dictionaryWithObject:[UIColor blueColor] forKey:UITextAttributeTextColor];
[self.segmentController
setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected];
答案 0 :(得分:0)
您还必须为正常状态(UIControlStateNormal
)明确设置任何属性。
答案 1 :(得分:0)
试试这个:
NSDictionary *textAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:13],
UITextAttributeTextColor: UIColorFromRGB(0x93938D),
UITextAttributeTextShadowColor: [UIColor clearColor]
};
[self.segmentController setTitleTextAttributes:textAttributes forState:UIControlStateNormal];
[self.segmentController setTitleTextAttributes:textAttributes forState:UIControlStateSelected];