hinterbu hinterbu - 11 months ago 48
iOS Question

Difference between setting self.view.opaque = NO and setting the background color to clearColor?

Just wondering what would the difference be between setting the

property of a (background) view to
, vs. simply setting the background colour of a view to '
'. If I do the latter, would it be the case then that there would be no need to also set the
property to
(as in
self.view.opaque = 0

Answer Source

All the difference in the world. They have nothing whatever to do with each other. Neither has any effect on the other.

opaque, if YES, sends a message to the drawing system about whether or not it can save some cycles by not having to composite this view with what is behind it.

backgroundColor is, uh, the color of the background. If the background color is opaque and the view's alpha is 1, it is your duty to set opaque to YES. It will not happen all by itself.

Big hint: I do hope you are not confusing opaque with layer's opacity or view's alpha. That is yet another thing.