UIView 的值为 YES 的 opaque 属性是否与其值为 [UIColor clearColor] 的 backgroundColor 属性冲突? [英] Is UIView's opaque property with a value of YES in conflict with its backgroundColor property with a value of [UIColor clearColor]?

查看:16
本文介绍了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 = YESview.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 属性冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆