iOS中关于UIButton缩进问题
2016-04-15 17:56
381 查看
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(97, 34, 174);"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(201, 27, 19);"></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(201, 27, 19);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSString</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> *string = </span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">测试</span><span style="font-variant-ligatures: no-common-ligatures">UIButton</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">文本缩进</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIButton</span><span style="font-variant-ligatures: no-common-ligatures"> *button = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIButton</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81">alloc</span><span style="font-variant-ligatures: no-common-ligatures">] </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81">CGRectMake</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">30</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">50</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">250</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">40</span><span style="font-variant-ligatures: no-common-ligatures">)];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> [button </span><span style="font-variant-ligatures: no-common-ligatures">setTitleColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">redColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">forState</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures">UIControlStateNormal</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> [button </span><span style="font-variant-ligatures: no-common-ligatures">setBackgroundColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">grayColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">]];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> [button </span><span style="font-variant-ligatures: no-common-ligatures">setTitle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:string </span><span style="font-variant-ligatures: no-common-ligatures">forState</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures">UIControlStateNormal</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">view</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligature 4000 s; color: #3d1d81">addSubview</span><span style="font-variant-ligatures: no-common-ligatures">:button];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// UIEdgeInsets insets = {top, left, bottom, right};</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;"><span style="font-variant-ligatures: no-common-ligatures"> </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">文本距从</span><span style="font-variant-ligatures: no-common-ligatures">button</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">左边</span><span style="font-variant-ligatures: no-common-ligatures">10</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">个像素的位置开始</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;"><span style="font-variant-ligatures: no-common-ligatures"> </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">文本距从</span><span style="font-variant-ligatures: no-common-ligatures">button</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">上边</span><span style="font-variant-ligatures: no-common-ligatures">10</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">个像素的位置开始</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// button.titleEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 0);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;"><span style="font-variant-ligatures: no-common-ligatures"> </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">文本距从</span><span style="font-variant-ligatures: no-common-ligatures">button</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">下边</span><span style="font-variant-ligatures: no-common-ligatures">10</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">个像素的位置开始</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 10, 0);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;"><span style="font-variant-ligatures: no-common-ligatures"> </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">文本距从</span><span style="font-variant-ligatures: no-common-ligatures">button</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">右边</span><span style="font-variant-ligatures: no-common-ligatures">10</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">个像素的位置开始</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">// button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);</span></p>
相关文章推荐
- iOS开发之路--微博“更多”页面
- iOS开发之路--微博骨架搭建
- iOS开发使用JSON解析网络数据
- IOS开发代码分享之获取启动画面图片的string
- iOS开发实现音频播放功能
- iOS开发之视图切换
- iOS开发使用XML解析网络数据
- IOS开发实现录音功能
- iOS开发之UIScrollView详解
- IOS开发之路--C语言数组和字符串
- iOS开发之触摸事件
- IOS开发代码分享之用nstimer实现倒计时功能
- iOS开发使用GDataXML框架解析网络数据
- iOS开发之UITableView详解
- iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片上下垂直居中对齐
- IOS开发代码分享之设置UISearchBar的背景颜色
- Swift之贪婪的UIButton
- ios推送证书
- iOS和tvOS游戏按需加载资源简介