我有一个自定义视图控制器,比如MyViewController
。它具有颜色属性,应使用UIAppearance
机制进行更改。我做了文档告诉要做的事情 - 将属性标记为UI_APPEARANCE_SELECTOR
。控制器符合UIAppearance
和UIAppearanceContainer
。当我试图运行应用程序时,我遇到了崩溃:
'+[MyViewController appearance]: unrecognized selector sent to class 0x10d6724f8'
为什么我的课程没有生成外观方法?是因为它是一个视图控制器而不是一个视图?如果是,那么这是否意味着自定义UIAppearance
属性仅支持UIView
s?
更新:发布一些代码示例:
@interface MyViewController : UIViewController <UIAppearance, UIAppearanceContainer>
@property (nonatomic) UIColor *blurTintColor UI_APPEARANCE_SELECTOR;
@end
...
// somewhere in theme setup codes which run when launching the app
MyViewController *cont = [MyViewController appearance];
cont.blurTintColor = [UIColor redColor];