Reputation: 11
I am trying to develop an iPhone application to set the UI Image.
Upvotes: 0
Views: 2551
Reputation: 34275
You can use cornerRadius
property
yourImageView.layer.cornerRadius = 5.0; //change value for your need
Upvotes: 0
Reputation: 13
You need QuartzCore framework for this.
#import <QuartzCore/QuartzCore.h> to your .h
filethen use
UIImageView *imgViw = [[UIImageView alloc] initWithImage:img];
imgViw.layer.cornerRadius = 10.0f;
imgViw.layer.borderWidth = 1.0;//For border
Upvotes: 0
Reputation: 6708
Get the layer of camBtn.
Setimage to that layer.
Add cornerradious to that layer.
The camBtn should be custombutton
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];
Upvotes: 1
Reputation: 1079
UIImageView *pic = [[UIImageView alloc] initWithImage: ...];
pic.layer.cornerRadius = 7.0f;
pic.layer.masksToBounds = YES;
Upvotes: 0
Reputation: 31722
use below code.
CALayer * l = [camBtn layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
Upvotes: 1
Reputation: 10312
set the proper radius value for this: UIImageView -> layer -> cornerRadius
Be sure to include QuartzCore.h
UIImageView* imgView = [[UIImageView alloc] initWithImage:image];
imgView.layer.cornerRadius = 15.0;
Where image is the image you wish to show. Display the above imageView to get the rounded effect
Upvotes: 0
Reputation: 31722
You could not set the corner of UIImage
instance because it's not inherited from UIView
,
So you need to create an UIImageView
instance by passing your UIImage
.
use the below 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];
Upvotes: 4