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

查看:155
本文介绍了UIView的opaque属性值是YES,与backgroundColor属性冲突,值为[UIColor clearColor]吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如代码:

view.opaque = YES;

view.backgroundColor = [UIColor clearColor];

任何人可以解释一下这个问题吗?

any one who can explain something about this?

编辑

如文件所示:


尽可能将视图声明为不透明



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 属性用于确定视图是否可以优化合成操作。

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的opaque属性值是YES,与backgroundColor属性冲突,值为[UIColor clearColor]吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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