I need to add Round corners to a UIImageView. I found a solution from a forum, and i tried the following code;
UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]];
// Get the Layer of any view
CALayer * l = [roundedView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
I am using iOS 5, and setMasksToBounds:YES and setCornerRadius are not found.
So is there any other way i could get round corners in my UIImageview ?
To make rounded corners on a
UIView(or its subclassUIImageView), you need, like you wrote in your question, to set the cornerRadius on your layer. For example:Import the right header and it will compile:
Don’t forget to link against it by adding it to your frameworks.