Making border with QuartzCore is slow?

Go To


When i try to do a border to a view my view become slow

[self.userView setBackgroundColor:[UIColor whiteColor]];
[self.userView.layer setMasksToBounds:YES];
[self.userView.layer setCornerRadius:15.0f];
[self.userView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[self.userView.layer setBorderWidth:1.0f];
2012-04-04 02:46
by keep on you


You might want to set the shouldRasterize property of your layer to YES.

2012-04-04 02:56
by omz
Terrible solution, it makes it ugl - Tom 2013-03-24 21:07
@Tom Perfect solution actually, rasterisation is the only way to optimise performance in this case. See my answer on how to improve the quality - Leon Storey 2013-04-01 02:45
Thanks omz this works.. - Rohit 2013-11-14 09:54


This is a follow on from omz's answer to improve the quality of the rasterised layer, to prevent pixelation you need to set the rasterisation scale too.

[self.userView.layer setShouldRaterize:YES];
[self.userView.layer setRasterizationScale:[UIScreen mainScreen].scale];
2013-04-01 02:48
by Leon Storey