UIAppearence Protocol

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文件中.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值