UIButton设置为圆形按钮并增加边框
2015-09-10 14:47
423 查看
设置按钮的长和宽尺寸一致(即为正方形),然后将圆角半径设为边长的一半,即形成一个圆形
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; btn.frame = CGRectMake(100, 100, 100, 100); // 设置按钮四个圆角的半径,默认为0,这里取边长一半便是一个圆 btn.layer.cornerRadius = 50.0; // 设置边框的宽度 btn.layer.borderWidth = 1.0; CGColorSpaceRef spaceRef = CGColorSpaceCreateDeviceRGB(); CGColorRef colorRef = CGColorCreate(spaceRef, (CGFloat[]){255/255.0, 0/255.0, 0/255.0, 1}); // 设置边框的颜色 btn.layer.borderColor = colorRef; btn.backgroundColor = [UIColor lightGrayColor]; [btn setTitle:@"Button" forState:UIControlStateNormal];
相关文章推荐
- 自定义UITextField背景图片
- Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the desi
- Bluetooth 分析Enable流程
- Reveal调试UI工具的使用
- android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
- U3D里UI相关逻辑和文件的组织关系的各种形式的比较
- iOS UUID deprecated corebluetooth
- iOS如何利用UITableView实现单选效果
- JAVA UUID 生成
- UnexpectedValueException Could not parse version constraint ^1.0.2: Invalid version string “^1.0.2”
- ubuntu12.04 create SAP issues
- SAP SD 顾问面试问题 consultant interview questionnaire
- Build Settings中的变量@rpath,@loader_path,@executable_path
- request与session区别
- 改变UITextField PlaceHolder的字体和颜色,不影响正常输入
- PowerBuilder12.5和PowerBuilder12.6数据管道的问题
- Exception occurred during processing request: null java.lang.NullPointerException
- UIActivityIndicatorView
- UI一揽子计划 13 (UITabBarController 、UITabBar、UITabBarItem 、Block传值)
- UI一揽子计划 12 (模态ViewController、单例、通讯录实战、)