I wanted to have an UIImageView appear with rounded corners, and found the following code to do it on Stack Overflow:
loginImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"BlueSky.jpg"]];
CALayer *l = [loginImage layer];
[l setMasksToBounds:YES];
[l setCornerRadius:5.0];
[loginImage release];
I added this code to my viewDidLoad method, but unfortunately the UIImageView does not give me the rounded corners I was expecting. I linked the imageview “loginImage” correctly in Interface Builder.
Any ideas what I’m doing wrong here?
Thanks!
If you create your UIImageView with Interface Builder, you actually do not need to create it manually in code.
So, if you create your UIImageView with IB, the code should look like this.
also, for beginners is good to read memory management