[关闭]
@fiy-fish 2016-12-04T01:56:34.000000Z 字数 2062 阅读 2829

iOS开发-Alpha,Hidden与Opaque区别

iOS


注意:
1.UIViewbackgroudColor 的alpha 值不会传递到subviews.
2. clear color 的alpha值就是0;
3. UIViewalpha值会影响backgroudColoralpha值。 如self.View.alpha=0.8 ,self.view.backgroudColor.alpha=0.5backgroudColor的最终alpha值为0.8*0.5 = 0.4

  1. 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.
  2. An opaque view is expected to fill its bounds with entirely opaque contentthat 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.
  3. You only need to set a value for the opaque property for subclasses of UIView that draw their own content using the drawRect: method. The opaque property has no effect for system provided classes such as UIButton, UILabel, UITableViewCell, etc.

翻译一下:
使用 opaque 可以提高系统的视图绘制性能,当opaque = yes时,系统可以快速高效的绘制视图,这个时候view的alpha一定等于1
view.alpha小于1时,opaque一定要设置为NO,否则会发生意想不到的后果
1.opaque默认为YES,此时view.alpha=1
2.view,alpha小于1时,opaque一定要设置为NO


Alpha,Hidden与Opaque 在内存消耗上的区别


参考

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注