How do opaque
alpha
and the opacity of the background work together for a UIView and what are the differences between them?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
opaque
means don't draw anything underneath, even if you are transparent.The background color's alpha only affects the background color's transparency, not anything else drawn on the view.
alpha
affects everything drawn on the view.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 toNO
iOS will have to blend your view with the view underneath, even if it doesn't happen to contain any transparency.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).
To the very good answer by deanWombourne it's worth to add that, unless you don't draw your own content using the drawRect: method, the opaque property has no effect.
Apple's doc:
If you draw your own content, keep in mind, that opaque is just a hint
and some more guidelines from the same Apple's doc: