iOS---设置btn边框
来源:互联网 发布:华为软件管理流程 编辑:程序博客网 时间:2024/06/05 02:16
[_btn1.layersetMasksToBounds:YES];
[_btn1.layersetCornerRadius:3.0];//设置矩圆角半径
[_btn1.layersetBorderWidth:1.0]; //边框宽度
CGColorSpaceRef colorSpace =CGColorSpaceCreateDeviceRGB();
CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 217/255.0, 217/255.0, 217/255.0, 1 });
[_btn1.layersetBorderColor:colorref];//边框颜色
--------------------------------------------------------------------
链接:http://www.zhihu.com/question/21710875/answer/21738384
如果只是简单地加一个边框的话,可以这样:
UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeSystem];
// 初始化工作,设置文字,frame等等,略
// 按钮边框宽度
yourButton.layer.borderWidth = 1.5;
// 设置圆角
yourButton.layer.cornerRadius = 4.5;
// 设置颜色空间为rgb,用于生成ColorRef
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// 新建一个红色的ColorRef,用于设置边框(四个数字分别是 r, g, b, alpha)
CGColorRef borderColorRef = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 });
// 设置边框颜色
yourButton.start.layer.borderColor = borderColorRef;
另外,这里有一个精彩的例子,推荐一下:
http://code4app.com/ios/UIButton-Bootstrap/52635e8c6803fa576b000000
- iOS---设置btn边框
- 给btn设置边框
- iOS -- btn
- iOS设置边框、圆角
- iOS 设置view的边框
- iOS - UITextView 边框的设置
- 30 iOS 设置UITextView 设置边框
- iOS btn文字居左
- iOS UIView 阴影 边框 边框宽度 包边 设置详解
- iOS - UIButton设置圆角和边框及边框颜色
- IOS UIImageview 添加边框 或者设置成圆角
- [IOS]UIButton 圆角/边框设置 相关
- IOS 设置任意控件圆角边框
- IOS开发之----设置UITableView边框(
- iOS 设置UIView的边框和阴影
- iOS 开发--设置View的边框阴影
- iOS-设置视图的边框
- iOS开发 -- 设置tableView的边框
- Maven中的DependencyManagement和Dependencies
- Echarts饼图柱形图调整文字大小(java代码)
- eclipse快捷键的导出导入
- 第十三周项目4-Floyd算法的验证
- js必包题
- iOS---设置btn边框
- Tab Control控件简单使用
- 第十二周项目3——图的遍历(2)-广度优先
- 统计字符串中英文字母、汉字、空格、数字及其他字符出现的字数
- 第十一周-用二叉树解代数表达式
- 今天是我上班第三天
- ProgressBar及其子类
- Gabor特征
- 测试