ios开发之View属性hidden, opaque, alpha的区别

1. @property(nonatomic) CGFloat alpha;
This value affects only the current view and does not affect any of its embedded subviews . Changes to this property can be  animated .
2. @property(nonatomic, getter=isHidden) BOOL hidden;
The default value is NO.
A hidden view disappears from its window and  does not receive input events . It remains in its superview’s list of subviews , however, and participates in autoresizing as usual. Hiding a view with subviews has the effect of hiding those subviews and any view descendants they might have . This effect is implicit and does not alter the hidden state of the receiver’s descendants .
3. @property(nonatomic, getter=isOpaque) BOOL opaque;
This property provides a hint to the drawing system as to how it should treat the view. If set to YES, the drawing system treats the view as fully opaque, which allows the drawing system to optimize some drawing operations and improve performance.  If set to NO, the drawing system composites the view normally with other content. The default value of this property is YES.
You should always set the value of this property to NO if the view is fully or partially transparent.

alpha支持 animation, hidden和opaque不支持
hidden开销小,alpha=0透明开销大,如果效果一样,用hidden好一点.
hideen的时候view是不接收事件的, 但alpha为0接收
上面的英文文档有一点挺重要的,当把View设置为透明的背景时,一般把opaque设置为NO,可以减少开销,对内存也好.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值