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?
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];
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;
你可以做圆边
yourview.layer.cornerRadius = 8.0; // or other value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.