Search code examples
iphoneuiviewcalayerrounded-cornersaqgridview

UIView: Rounded Corners Without Performance Issues


I am using an AQGridView to display my data in a grid on iPad. Every cell is a UIView subclass and typically, there are 18 cells displayed simultaneously.

I would like to add a round corner to these cells, so I set the cornerRadius property of the relevant layers (i.e. the layer of the main UIView and of one subview). However, this results in performance issues and the scrolling is not smooth any more. When using other CALayer properties, such as shadowOpacity, this does not happen.

Are there any other ways to add a rounded corner (apart from using an image)? Or am I doing something wrong?


Solution

  • I also saw a major performance hit when using cornerRadius on the layer of a view that contained a UIImageView subview. Rasterization solved that problem: view.layer.shouldRasterize = YES;