views:

92

answers:

1

Hi,

I need to add rounded corners to an image in a UITable View cell to 3px. What's the best way to go about this? Apparently you can use the quartz framework?

Thanks.

+1  A: 

The easiest way to get rounded corners is Core Animation:

imageView.layer.cornerRadius = 3.0f;
Ole Begemann
I get an error "Request for member Layer is something not a structure or union". Any ideas?
Graeme
You need to `#import <QuartzCore/QuartzCore.h>` and add the QuartzCore.framework to your target.
Ole Begemann
I've already done that - still no good though. Any other ideas? Thanks btw.
Graeme
Well, if you really wrote "Layer" with a capital L it's no wonder you get an error message.
Ole Begemann
No, I wrote it as image.layer.cornerRadius = 3.0f; To add the framework I right clicked the Frameworks folder, selected "Add Existing Framework" and chose the Quartz Framework. I then added the #import <QuartzCore/QuartzCore.h> to the header of the table view.
Graeme
So what is `image`? You need to apply this to a `UIImageView`, not a `UIImage`.
Ole Begemann
image is a UIImage so um what's the best way for a UIImage to get rounded corners then I guess?
Graeme
Try: CALayer * layer = imageView.layer; layer.cornerRadius = 3.0f;
Kenny