iOS开发:View的属性 hidden、alpha、opaque
2017-03-02 00:00
633 查看
区别:每个View都有hidden、alpha、opaque三个关于透明的属性;
官方文档的介绍:
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.
1、alpha
(1)这个属性只能影响当前视图,不连带影响子视图;
(2)可以当做动画进行动态改变;
(3)alpha = 0 时仍旧接收事件,但是这个操作比hidden开销大
2、hidden
(1)默认为no,即为显示;
(2)hidden的视图不再接收事件;
(3)hidden的视图仍然在父视图的子视图列表里,而且响应自适应事件;
(4)hidden的视图所有子视图也会被hidden而且它们的hidden属性不会变;
3、opaque
(1)如果opaque设置为TRUE,那么视图会被当做全视图来对待,系统会重绘整个视图;
(2)如果opaque设置为FALSE,那么系统会减少开销,以其中的内容来判定重绘额视图;
(3)如果把视图的背景色设置为透明那个,那么opaque最好设置为FALSE,减少开销;
官方文档的介绍:
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.
1、alpha
(1)这个属性只能影响当前视图,不连带影响子视图;
(2)可以当做动画进行动态改变;
(3)alpha = 0 时仍旧接收事件,但是这个操作比hidden开销大
2、hidden
(1)默认为no,即为显示;
(2)hidden的视图不再接收事件;
(3)hidden的视图仍然在父视图的子视图列表里,而且响应自适应事件;
(4)hidden的视图所有子视图也会被hidden而且它们的hidden属性不会变;
3、opaque
(1)如果opaque设置为TRUE,那么视图会被当做全视图来对待,系统会重绘整个视图;
(2)如果opaque设置为FALSE,那么系统会减少开销,以其中的内容来判定重绘额视图;
(3)如果把视图的背景色设置为透明那个,那么opaque最好设置为FALSE,减少开销;
相关文章推荐
- 转载: ios开发之View属性hidden, opaque, alpha的区别
- iOS开发——View的透明属性hidden、alpha、opaque
- ios开发之View属性hidden, opaque, alpha, opacity的区别
- ios开发之View属性hidden, opaque, alpha, opacity的区别
- iOS开发之View属性hidden, opaque, alpha的区别
- ios开发之View属性hidden, opaque, alpha的区别
- ios开发之View属性hidden, opaque, alpha, opacity的区别
- ios开发之View属性hidden, opaque, alpha的区别
- IOS - View属性hidden, opaque, alpha, opacity的区别
- iOS开发-Alpha,Hidden与Opaque区别
- iOS开发-Alpha,Hidden与Opaque区别
- iOS 中 UIView属性hidden, opaque, alpha的区别
- [BS-17] iOS开发-Alpha,Hidden和Opaque区别
- iOS开发 剖析网易新闻标签栏视图切换(addChildViewController属性介绍)
- 转载 iOS开发 剖析网易新闻标签栏视图切换(addChildViewController属性介绍)
- 【iOS开发-10】UIProgressView进度条的几个属性介绍
- UIView的alpha、hidden和opaque属性之间的关系和区别
- ios开发 - UIImageView 的contentMode属性应用
- IOS学习笔记(十二)之IOS开发之表视图(UITableView)的相关类,属性与表视图实现学习(二)
- UIView的alpha、hidden和opaque属性之间的关系和区别