Reputation: 616
I want to draw an Item that similar as item of iPhone. I have also draw with UIView like this
But the item I want like this :
How can I draw like round buttton?
Upvotes: 1
Views: 180
Reputation: 1408
USE THIS CODE
UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
[bt setFrame:CGRectMake(10, 10, 50, 50)];
[bt setImage:[UIImage imageNamed:@"abc.png" ] forState:UIControlStateNormal];
// Get the Layer of any view
CALayer * l = [bt layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
// You can even add a border
[l setBorderWidth:4.0];
[l setBorderColor:[[UIColor blueColor] CGColor]];
[self.view addSubview:bt];
Upvotes: 2
Reputation: 8180
You can make round edges by
yourview.layer.cornerRadius = 8.0; // or other value
Upvotes: 1
Reputation: 9740
Set the corner Radius of your view and insert the label below it.
iPhone supports the cornerRadius property on the CALayer class. Every view has a CALayer instance that you can manipulate.
First of all #import <QuartzCore/QuartzCore.h>
and link to the QuartzCore framework
to get access to CALayer's headers and properties.Then,
yourView.layer.cornerRadius = 8;
Upvotes: 1