My scroll has some views that is cornerRadius = 10.0 and masksToBounds = YES.
This causes a performance issue for scrolling my scroll view. Though I tried each view’s shouldRasterize is set YES, the issue is not solved.
However, I know the solution for this issue. That is what masksToBound is set NO. (masksToBound's default value is NO)
Although masksToBound is NO, my views’s corners still have curve and the performance issue is solved, too.
I want to know about relation between cornerRadius and masksToBounds. I’m afraid of unexpected issues with this setting.
Thank you.
After providing
cornerRadiuswhich specifies a radius used to draw the rounded corners of the receiver’s background.Now it depends on
masksToBoundswhich determines if the sublayers are clipped to the receiver’s bounds. So if it is set toYES, an implicit mask matching the layer bounds is applied to the layer, including the effects of thecornerRadiusproperty. If it is set toYESand a mask property is specified, the two masks are multiplied to get the actual mask values.For example:
If you set that on a
CALayerwith image contents, the image will still be drawn outside the corner radius boundary. You can solve this by settingsublayer.masksToBoundstoYES; but if you do that, the shadows won’t show up because they’ll be masked out!