2

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

MDMonty
  • 363
  • 2
  • 10

1 Answers1

1

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

Eiko
  • 25,601
  • 15
  • 56
  • 71
  • 1
    One exception I've found is if you'll be changing the image view's `image` property frequently, such as when it's part of a reusable table view cell. In this case, I found pre-rendering to provide noticeably smoother scrolling (at least on the original iPhone, and, to a lesser extent, 3GS). – Daniel Dickison Nov 22 '10 at 17:53
  • Thanks guys, I appreciate you taking the time to respond. – MDMonty Nov 22 '10 at 23:41