Make superlayer not visible
I have added sublayers to my UIView's layer. However, t开发者_Go百科he root layer(UIView's layer) is visible at background as white rectangle. How can I effeciently hide superlayer so there will be no resourses spent on compositing with sublayers?
If you just want to hide the white rectangle, you can set the superlayer's opaque property to NO, its background color to a clear color (zero alpha), or you can set its frame to CGRectZero (if it's a UIView layer, that's not a good idea). However, note that there's always something behind your view, so making the background layer transparent/invisible doesn't exclude layer compositing. The only things that affect layer compositing speed are sublayer opaqueness and masks.
I would just set the UIView's background color to [UIColor clearColor] and its opaque property to false, and measure the effect in Instruments.
Set the UIView's backgroundColor to [UIColor clearColor] and the opaque property to NO.
精彩评论