我想画一个与iPhone的项目相似的项目。我也用UIView画过这样的图

但我想要的东西如下:

我怎么才能画得像圆形纽扣呢?
发布于 2012-08-23 14:32:22
设置视图的拐角半径,并在其下方插入标签。
iPhone支持CALayer类的cornerRadius属性。每个视图都有一个可以操作的CALayer实例。
首先使用#import <QuartzCore/QuartzCore.h>并链接到QuartzCore framework以访问CALayer的报头和properties.Then,
yourView.layer.cornerRadius = 8;发布于 2012-08-23 14:35:51
使用此代码
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];发布于 2012-08-23 14:33:20
您可以通过以下方式创建圆形边
yourview.layer.cornerRadius = 8.0; // or other valuehttps://stackoverflow.com/questions/12085908
复制相似问题