您的位置:首页 > 产品设计 > UI/UE

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

2014-11-05 11:02 417 查看
文章转载自 http://blog.csdn.net/caryaliu/article/details/7837916

1. @property(nonatomic) CGFloat alpha;

The value of this property is a floating-point number in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque.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;

A Boolean value that determines whether the receiver is hidden.

Setting the value of this property to YES hides the receiver and setting it to NO shows the receiver. 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.

Hiding the view that is the window’s current first responder causes the view’s next valid key view to become the new first responder.

The value of this property reflects the state of the receiver only and does not account for the state of the receiver’s ancestors in the view hierarchy. Thus this property can be NO but the receiver may still be hidden if an ancestor is hidden.

3. @property(nonatomic, getter=isOpaque) BOOL opaque;

A Boolean value that determines whether the receiver is 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.

An opaque view is expected to fill its bounds with entirely opaque content—that is, the content should have an alpha value of 1.0. If the view is opaque and either does not fill its bounds or contains wholly or partially transparent content, the results are
unpredictable. You should always set the value of this property to NO if the view is fully or partially transparent.

These properties affect the opacity of the view. The alpha and hidden properties change the view’s opacity directly.

The opaque property tells the system how it should composite your view. Set this property to YES if your view’s content is fully opaque and therefore does not reveal any of the underlying view’s content. Setting this property to YES improves performance by
eliminating unnecessary compositing operations.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios开发