UIView:不透明 vs. alpha vs. 不透明 [英] UIView: opaque vs. alpha vs. opacity
问题描述
opaque
alpha
和背景的不透明度是如何在 UIView 中协同工作的,它们之间有什么区别?
How do opaque
alpha
and the opacity of the background work together for a UIView and what are the differences between them?
UIView http://i.minus.com/jb2IP8TXbYTxKr.png
推荐答案
opaque
意味着不要在下面画任何东西,即使你是透明的.
opaque
means don't draw anything underneath, even if you are transparent.
背景颜色的 alpha 只影响背景颜色的透明度,不会影响视图上绘制的任何其他内容.
The background color's alpha only affects the background color's transparency, not anything else drawn on the view.
alpha
影响在视图上绘制的所有内容.
alpha
affects everything drawn on the view.
不透明属性可以提高速度 - 如果您知道您的视图永远没有透明度,您可以将其设置为 YES
并且当 iOS 呈现您的视图时可以进行一些性能优化并更快地渲染它.如果将其设置为 NO
,iOS 将不得不将您的视图与下面的视图混合,即使它不包含任何透明度.
The opaque property can give you a speed increase - if you know that your view will never have transparency you can set this to YES
and when iOS renders your view it can make some performance optimisations and render it faster. If this is set to NO
iOS will have to blend your view with the view underneath, even if it doesn't happen to contain any transparency.
alpha 也会影响背景颜色的 alpha,即如果背景颜色是 0.5 透明并且 alpha 也是 0.5,这会使背景视图的 alpha 为 0.25 (0.5 * 0.5).
The alpha will also affect the alpha of the backround color i.e. if the background color is 0.5 transparent and the alpha is also 0.5, this has the effect of making the background view's alpha 0.25 (0.5 * 0.5).
这篇关于UIView:不透明 vs. alpha vs. 不透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!