简体   繁体   中英

Adding Rounded Corners to UIImageView vs Pre-Rendering the UIImage?

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM