所以我试图改变我的 UISegmentedControl 的标题的文本属性,但它不起作用,没有任何改变。我还应用了自定义背景和分隔线,它可以正常工作,但不是这个。
NSDictionary *normaltextAttr =
@{[UIColor blackColor]: UITextAttributeTextColor,
[UIColor clearColor]: UITextAttributeTextShadowColor,
[UIFont fontWithName:_regularFont size:20.f]: UITextAttributeFont};
NSDictionary *selectedtextAttr =
@{[UIColor colorWithRed:135.0/255.0 green:135.0/255.0 blue:135.0/255.0 alpha:1.0]: UITextAttributeTextColor,
[UIColor clearColor]: UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)]: UITextAttributeTextShadowOffset,
[UIFont fontWithName:_regularFont size:0.0]: UITextAttributeFont};
[[UISegmentedControl appearance] setTitleTextAttributes:normaltextAttr
forState:UIControlStateNormal];
[[UISegmentedControl appearance] setTitleTextAttributes:selectedtextAttr
forState:UIControlStateSelected];