UIAppearance not taking effect on UILabels created programmatically

前端 未结 5 1948
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 07:34

We have extended UILabel to be able to apply standard fonts and colors for all uses of a given label type in our apps. Eg.

@interface UILabelHeadingBold : UILab         


        
5条回答
  •  遥遥无期
    2021-02-07 08:26

    From Apple documentation :

    To support appearance customization, a class must conform to the UIAppearanceContainer protocol and relevant accessor methods must be marked with UI_APPEARANCE_SELECTOR.

    For example in UINavigationBar.h, tintColor is marked with UI_APPEARANCE_SELECTOR

    @property(nonatomic,retain) UIColor *tintColor UI_APPEARANCE_SELECTOR;
    

    But in UILabel.h you can see that the textColor and font propertys are not marked with UI_APPEARANCE_SELECTOR but somehow it works when added in Interface Builder (following the documentation it shouldn't work at all).

提交回复
热议问题