appearance
+ (instancetype)appearance;
该属性能够定制一个类的事例的外观.发送和外观(appearence)相关的消息给这个类的appearence代理.
例如去修改UINavigationBar
实例的bar的tint color可以用下面的代码:
[[UINavigationBar appearance] setBarTintColor:myColor];
在iOS7,tintColor这个属性移到了UIView,并且继承了一些特殊的行为.
继承的行为会与appearance代理产生冲突,所以tintColor不再允许在appearance代理中了.
UI_APPEARANCE_SELECTOR
UI_APPEARANCE_SELECTOR
的定义:
#define UI_APPEARANCE_SELECTOR __attribute__((annotate("ui_appearance_selector")))
可以看出这时一个宏.
作为appearance 代理API的一部分,在header中用来标记外观属性的selector,
例如:
- (void)setProperty:(PropertyType)property forAxis1:(IntegerType)axis1 axis2:(IntegerType)axis2 axisN:(IntegerType)axisN;
- (PropertyType)propertyForAxis1:(IntegerType)axis1 axis2:(IntegerType)axis2 axisN:(IntegerType)axisN;
这里的PropertyType
可以是iOS中的任何标准类型: id, NSInteger, NSUInteger, CGFloat, CGPoint, CGSize, CGRect, UIEdgeInsets or UIOffset.
IntegerType必须要么是NSInteger或NSUInteger;
如果不是的话,那么会抛出异常的.
所有内容摘自
UIAppearance.h
文件中.