Is UIView#39;s opaque property with a value of YES in conflict with its backgroundColor property with a value of [UIColor clearColor]?(UIView 的值为 YES 的 opaque 属性是否与其值为 [UIColor clearColor] 的 backgroundColor 属性冲突?)
问题描述
如代码:
view.opaque = YES;
和
view.backgroundColor = [UIColor clearColor];
谁能解释一下?
如文档所示:
UIKit 使用每个视图的 opaque 属性来确定视图是否可以优化合成操作.对于自定义视图,将此属性的值设置为 YES 会告诉 UIKit 它不需要在视图后面呈现任何内容.较少的渲染可以提高您的绘图代码的性能,通常是鼓励的.当然,如果您将 opaque 属性设置为 YES,您的视图必须用完全不透明的内容完全填充其边界矩形.
Declare Views as Opaque Whenever Possible
UIKit uses the opaque property of each view to determine whether the view can optimize compositing operations. Setting the value of this property to YES for a custom view tells UIKit that it does not need to render any content behind your view. Less rendering can lead to increased performance for your drawing code and is generally encouraged. Of course, if you set the opaque property to YES, your view must fills its bounds rectangle completely with fully opaque content.
不透明属性用于确定视图是否可以优化合成操作.
opaque property is used for determining whether the view can optimize compositing operations.
所以问题是:
如果我设置view.opaque = YES
和view.backgroundColor = [UIColor clearColor]
,前者性能提升,后者呢?
if i set view.opaque = YES
and view.backgroundColor = [UIColor clearColor]
,the former increased performance,how about the latter?
推荐答案
不,不应该.它应该表现得很清楚.颜色清晰是完全不透明的,如果这有道理的话.如果您更改其 alpha,它将不会显示为黑色或白色或其他任何内容.会很清楚的.
No, it shouldn't be. It should act clear. The color clear is completely opaque, if that even makes sense. It won't show up black or white or anything else if you change its alpha. It will be clear.
这篇关于UIView 的值为 YES 的 opaque 属性是否与其值为 [UIColor clearColor] 的 backgroundColor 属性冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIView 的值为 YES 的 opaque 属性是否与其值为 [UIColor clearColor] 的 backgroundColor 属性冲突?


- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01