0
這裏是正在建立,它是接近的顏色,我需要:通過外觀代理設置的UIBarButtonItem的文本顏色
NSDictionary *barButtonItemTitleAttributesEnabled = @{
NSFontAttributeName:[UIFont MRFontLightOfSize:17],
NSForegroundColorAttributeName:[UIColor whiteColor]
};
NSDictionary *barButtonItemTitleAttributesDisabled = @{
NSFontAttributeName:[UIFont MRFontLightOfSize:17],
NSForegroundColorAttributeName:[UIColor colorWithWhite:1.0f alpha:0.25f]
};
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesEnabled forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesDisabled forState:UIControlStateDisabled];
但我更喜歡以某種方式設置禁用文本顏色相同的顏色選擇狀態,有沒有辦法做到這一點與外觀代理調用?
還試圖這樣:
NSDictionary *barButtonItemDisabled = [[UIBarButtonItem appearance] titleTextAttributesForState:UIControlStateSelected];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesEnabled forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemDisabled forState:UIControlStateDisabled];
就是這裏了您的問題,你想要得到的文本顏色當你按下按鈕時系統設置?所以如果你的按鈕是紅色,當你按下它使它有點不同紅色?只是想在證明答案之前確認我的理解 – random
如果你想要相同的顏色,然後通過相同的顏色。 – rmaddy