2014-05-08 88 views
0

我正在使用它來更改分段控件文本的文本顏色,但其顏色在UIControlStateNormal中未發生變化。我必須保持兩種狀態相同的顏色。UISegmentedControl文本顏色問題

NSDictionary *highlightedAttributes = [NSDictionary 
    dictionaryWithObject:[UIColor blueColor] forKey:UITextAttributeTextColor]; 
[self.segmentController 
    setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected]; 

回答

0

您還必須爲正常狀態(UIControlStateNormal)明確設置任何屬性。

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];