iOS中关于UIButton缩进问题

来源:互联网 发布:兰蔻网络推广方案 编辑:程序博客网 时间:2024/04/30 15:06
<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-ligatures; 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>
0 1