iOS - UIButton设置圆角和边框及边框颜色

来源:互联网 发布:c 编程 文件被截断 编辑:程序博客网 时间:2024/05/16 23:57


[box.actionButton.layer setMasksToBounds:YES];      [box.actionButton.layer setCornerRadius:10.0]; //设置矩形四个圆角半径      //边框宽度      [box.actionButton.layer setBorderWidth:1.0];      //设置边框颜色有两种方法:第一种如下:      CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();      CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 0, 1 });      [box.actionButton.layer setBorderColor:colorref];//边框颜色      //第二种方法如下:      //_testButton.layer.borderColor=[UIColor grayColor].CGColor;  

原文:http://www.open-open.com/code/view/1432392001083






0 0