zoukankan      html  css  js  c++  java
  • iOS开发——View的透明属性hidden、alpha、opaque

    Hidden、Alpha、Opaque的区别

    在iOS中,每个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
      • 这个属性只能影响当前视图,不能连带影响子视图
      • 可以当做动画进行动态改变
      • alpha = 0 时仍旧接收事件,但是这个操作比Hidden开销大
    2. hidden
      • 默认为NO,就是显示状态
      • hidden的视图不再接收事件
      • hidden的视图仍然在父视图的子视图列表里,而且响应自适应autoresizing的事件
      • hidden的视图所有子视图也会被Hidden而且它们的Hidden属性不会被改变
    3. opaque
      • 如果opaque设置为YES,那么视图会被当做全视图来对待,系统会重绘整个视图
      • 如果opaque设置为NO,那么系统会减少开销,以其中的内容来判定重绘的视图
      • 如果把视图的背景色设置为透明那个,那么opaque最好设置为NO,减少开销
  • 相关阅读:
    VS2010 修改模板文件,增加默认注释
    Substring方法(C#,JS,Java,SQL)的区别
    好的架构是进化来的,不是设计来的
    SQL Server编程系列(2):SMO常用对象的有关操作
    (转) SQL Server编程系列(1):SMO介绍
    SQL Server的分页优化及Row_Number()分页存在的问题
    CTE(Common Table Expression) 公用表表达式
    SSH加密原理、RSA非对称加密算法学习与理解
    asp.net 项目目录说明
    【转】SOA架构设计经验分享—架构、职责、数据一致性
  • 原文地址:https://www.cnblogs.com/wisejoker/p/4036624.html
Copyright © 2011-2022 走看看