6
Upto iOS 10,禁用和啓用uibarbuttonitem的字體保持不變,只有顏色不同。但是,我安裝我的應用程序在設備上有ios 11後,禁用模式的字體得到更新(顯示系統字體),而在啓用模式下,它顯示了我設置的適當字體。禁用時更新UIBarbuttonItem字體 - iOS 11
因此,對於iOS 11的情況,我如何設置禁用模式的字體以保持應用程序的一致性。
Upto iOS 10,禁用和啓用uibarbuttonitem的字體保持不變,只有顏色不同。但是,我安裝我的應用程序在設備上有ios 11後,禁用模式的字體得到更新(顯示系統字體),而在啓用模式下,它顯示了我設置的適當字體。禁用時更新UIBarbuttonItem字體 - iOS 11
因此,對於iOS 11的情況,我如何設置禁用模式的字體以保持應用程序的一致性。
這似乎已經在iOS 11中發生了變化,至少在我使用UIAppearance協議的情況下。不知道這是一個錯誤還是故意。
我也發現我不能掩蓋值加在一起(如.normal|.disabled
),因爲它意味着它只能應用的字體,如果控制過程中滿足所有狀態。
所以我落得這樣做的:
for controlState in [UIControlState.normal, UIControlState.disabled, UIControlState.focused, UIControlState.highlighted, UIControlState.selected] {
barButton.setTitleTextAttributes([NSFontAttributeName: customFontName], for: controlState)
}
要更新它無處不在使用UIAppearance協議:
for controlState in [UIControlState.normal, UIControlState.disabled, UIControlState.focused, UIControlState.highlighted, UIControlState.selected] {
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: customFontName, for: controlState);
}