UIImageView设定圆角

<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 177, 255);"><span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">thumbnail</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> = [[</span>UIImageView<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> </span>alloc<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">] </span>init<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">]; </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 177, 255);"><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">        [</span><span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span>contentView<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> </span>addSubview<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">thumbnail</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(8, 250, 149);"><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">        [</span>_thumbnail<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> </span>mas_makeConstraints<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">:^(</span>MASConstraintMaker<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> *make) {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(255, 255, 255);">            make.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">top</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">equalTo</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #00b1ff">contentView</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">mas_top</span>).<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">offset</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #8b87ff">10</span>);</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(255, 255, 255);">            make.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">left</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">equalTo</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #00b1ff">contentView</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">mas_left</span>).<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">offset</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #8b87ff">20</span>);</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(255, 255, 255);">            make.<span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">size</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #eb905a">mas_equalTo</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #00b1ff">CGSizeMake</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #8b87ff">25</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #8b87ff">25</span>));</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(255, 255, 255);">        }];</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(255, 255, 255);"><span style="color: rgb(102, 102, 102); font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; line-height: 21.600000381469727px; background-color: rgb(247, 247, 247);"><span style="white-space:pre">	</span>//必須加上這一行,這樣圓角才會加在圖片的「外側」</span>
</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 177, 255);"><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #08fa95">thumbnail</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span>layer<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">.</span>masksToBounds<span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #de38a6">YES</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo;"><span style="white-space: pre;">	</span>//设定圆角的弧度为图片尺寸的一半</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo;">        <span style="color: rgb(222, 56, 166);">self</span><span style="color: rgb(255, 255, 255);">.</span><span style="color: rgb(8, 250, 149);">thumbnail</span><span style="color: rgb(255, 255, 255);">.</span><span style="color:#00b1ff;">layer</span><span style="color: rgb(255, 255, 255);">.</span><span style="color:#00b1ff;">cornerRadius</span><span style="color: rgb(255, 255, 255);"> = </span><span style="color: rgb(139, 135, 255);">12.5</span><span style="color: rgb(255, 255, 255);">;</span></p>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值