I am trying to develop an iPhone application to set the UI Image.
Asked
Active
Viewed 2,543 times
7 Answers
4
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];
Jhaliya - Praveen Sharma
- 31,697
- 9
- 72
- 76
-
i need set image to buttons so how to set round corners to image – Atchu Chitri Apr 22 '11 at 06:11
-
@ user674490: Then set the corner of your UIButton not image. Then use CALayer * l = [myButton layer]; [l setMasksToBounds:YES]; [l setCornerRadius:10.0]; – Jhaliya - Praveen Sharma Apr 22 '11 at 06:14
1
use below code.
CALayer * l = [camBtn layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
Jhaliya - Praveen Sharma
- 31,697
- 9
- 72
- 76
1
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];
Community
- 1
- 1
GameLoading
- 6,688
- 2
- 33
- 57
0
You need QuartzCore framework for this.
- Import QuartzCore Framwork
- Add
#import <QuartzCore/QuartzCore.h> to your .hfile
then use
UIImageView *imgViw = [[UIImageView alloc] initWithImage:img];
imgViw.layer.cornerRadius = 10.0f;
imgViw.layer.borderWidth = 1.0;//For border
VRN
- 13
- 3
0
You can use cornerRadius property
yourImageView.layer.cornerRadius = 5.0; //change value for your need
Krishnabhadra
- 34,169
- 30
- 118
- 167
0
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
Bourne
- 10,094
- 5
- 24
- 51
-
iam set the image to button so i need image should be rounded corners not a UI ImageView – Atchu Chitri Apr 22 '11 at 06:47
-
Then make a UIButton of UIButtonTypeCustom and set the above as the background image using the setBackgroundImage message – Bourne Apr 22 '11 at 07:01
0
UIImageView *pic = [[UIImageView alloc] initWithImage: ...];
pic.layer.cornerRadius = 7.0f;
pic.layer.masksToBounds = YES;
oOEric
- 1,069
- 1
- 10
- 25