UIButton设置为圆形按钮并增加边框
设置按钮的长和宽尺寸一致(即为正方形),然后将圆角半径设为边长的一半,即形成一个圆形
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(, , , ); // 设置按钮四个圆角的半径,默认为0,这里取边长一半便是一个圆
btn.layer.cornerRadius = 50.0;
// 设置边框的宽度
btn.layer.borderWidth = 1.0; CGColorSpaceRef spaceRef = CGColorSpaceCreateDeviceRGB();
CGColorRef colorRef = CGColorCreate(spaceRef, (CGFloat[]){/255.0, /255.0, /255.0, }); // 设置边框的颜色
btn.layer.borderColor = colorRef;
btn.backgroundColor = [UIColor lightGrayColor];
[btn setTitle:@"Button" forState:UIControlStateNormal];

UIButton设置为圆形按钮并增加边框的更多相关文章
- IOS8 设置TableView Separatorinset 分割线从边框顶端开始
IOS8 设置TableView Separatorinset 分割线从边框顶端开始 在ios8上 [TableViewsetSeparatorInset:UIEdgeInsetsMake(0,0 ...
- iOS 11 导航栏 item 偏移问题 和 Swift 下 UIButton 设置 title、image 显示问题
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- 用NPOI创建Excel、合并单元格、设置单元格样式、边框的方法
本篇文章小编为大家介绍,用NPOI创建Excel.合并单元格.设置单元格样式.边框的方法.需要的朋友参考下 今天在做项目中,遇到使用代码生成具有一定样式的Excel,找了很多资料,最后终于解决了,Ex ...
- iOS开发--UIButton 设置圆角 边框颜色 点击回调方法
UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signBtn.frame = CGRectMake(, , , ) ...
- UIButton 设置圆角 边框颜色 点击回调方法
UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signBtn.frame = CGRectMake(, , , ) ...
- UIButton设置圆角和边框及边框颜色
1. 按钮边框颜色 //设置边框颜色 [btn.layer setMasksToBounds:YES]; [btn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径 ...
- iOS中UIKit——UIButton设置边框
UIButton *testButton = [UIButton buttonWithType:UIButtonTypeSystem]; [testButton setFrame:CGRectMake ...
- iOS - UIButton设置文字标题下划线以及下划线颜色
创建button设置可以折行显示 - (void)viewDidLoad { [super viewDidLoad]; UIButton * button = [[UIButton alloc] in ...
- ios UIButton设置单选效果,以及同时设置图片和标题
一,设置单选效果 - (void)selectedBtnPress:(UIButton*)sender { //首先把原来按钮的选中效果消除 for (int i=0;i<num;i++) {/ ...
随机推荐
- array_map常用技巧
array_map() 函数将用户自定义函数作用到数组中的每个值上,并返回用户自定义函数作用后的带有新值的数组. 简单来说 “array_map” 会对数组中的每一项进行处理,并返回处理后的数据. 定 ...
- Android 打开其他程序
Intent intent = new Intent(); intent.setComponent(new ComponentName("所要打开的程序包名", "所要打 ...
- 细说Redis持久化机制
概述 Redis不仅能够作为缓存来使用,也能够作为内存数据库. Redis作为内存数据库使用时.必需要解决一个问题:数据的持久性.有些将Redis作为缓存使用的场景也需要将缓存的数据持久化到存储介质上 ...
- The bean 'xxx' could not be injected as a 'xxx'because it is a JDK dynamic proxy that implements
启动springboot项目的时候示以下错误 Error starting ApplicationContext. To display the conditions report re-run yo ...
- lucene 自定义评分 (给lucene自带的评分*我们filed的系数) 如搜索结果时间的加权
参见孔浩 lucene 22讲 步骤 1.写一个类继承于 CostomScoreQuery -->覆盖getCostomSorceProvider 方法 2.写一个自己的provider(重写c ...
- openssl之BIO系列之12---文件描写叙述符(fd)类型BIO
文件描写叙述符(fd)类型BIO ---依据openssl doc\crypto\bio_s_fd.pod翻译和自己的理解写成 (作者:DragonKing Mailwzhah@263.net 公布于 ...
- windows平台简易直播系统搭建
最近做直播系统的朋友很多,正好前端时间也在做这一块,写片文章分享下开发心得,以为后用. 直播系统我将它分为前堆推流,后台服务,客户端播放三大部分.前端推流基于ffmpeg,后台服务 使用crtmp服务 ...
- Centos 安装Puppet
环境说明: OS:CentOS 5.4 i386puppetmaster 192.168.0.12 hostname: puppetmaster.info.comclient ...
- POI-----POI操作Excel-4、字体
- Android开源git40个App源代码
(JamsMusicPlayer)非常棒的音乐播放器(new) (F8)日程安排的软件 (Conversations)基于XMPP的应用 (Bitocle)能够在手机上查看自己github ...