美文网首页iOS Developer
如何设置Button和ImageView的圆角度和边框宽度和颜色

如何设置Button和ImageView的圆角度和边框宽度和颜色

作者: 走在路上的小二 | 来源:发表于2016-11-24 10:20 被阅读228次

UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem]

[button.layer setMasksToBounds:YES];

[button.layer setCornerRadius:10.0];//设置矩形四个圆角半径

[button.layersetBorderWidth:1.0];//边框宽度

//设置边框颜色有两种方法:第一种如下:

CGColorSpaceRef colorSpace =CGColorSpaceCreateDeviceRGB();

CGColorRef colorref =CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 0, 1});

[button.layersetBorderColor:colorref];//边框颜色

//第二种方法如下:

button.borderColor=[UIColorgrayColor].CGColor;

PS: 有疑问欢迎留言。

相关文章

网友评论

    本文标题:如何设置Button和ImageView的圆角度和边框宽度和颜色

    本文链接:https://www.haomeiwen.com/subject/gidbpttx.html