<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>
UIImageView设定圆角
最新推荐文章于 2021-05-27 07:46:34 发布