Question

I am experimenting with the layer of a UIImageView, in particular adding rounded corners.

My question is, What is the impact on performance (if any) by doing the following :

[self.imgView.layer setCornerRadius:10.0f];
[self.imgView.layer setMasksToBounds:YES];
[self.imgView.layer setBorderWidth:2.0f];
[self.imgView.layer setBorderColor:[[UIColor yellowColor] CGColor]];

over 'Pre-Rendering' the image before hand.

Thank you

Was it helpful?

Solution

CoreAnimation in general is very fast - in fact, too fast to worry about it.

So if the original image can be of any value, or a different border is what you might need later, use those CALayer attributes.

I'd go with prerendered only if the border pattern is set in stone. Further, CA might speed things up from time to time when masking is involved as it allows you to use opaque images instead of transparent, so the region which needs alpha blending is considerably smaller (but no hard number on that one).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top