分享

[转载]ios开发之View属性hidden,opaque,alpha的区别

 最初九月雪 2015-06-10
我对这三个的区别不是很理解,下面大概总结一下
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. Itremains 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 anddoes 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,可以减少开销,对内存也好.

参考文档:http://blog.csdn.net/caryaliu/article/details/7837916

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多