【问题标题】:How to draw a 1 pixel-wide smooth border on a UIView, with a cornerRadius?如何在带有cornerRadius的UIView上绘制1像素宽的平滑边框?
【发布时间】:2014-09-08 12:25:02
【问题描述】:

这是我用来设置 UIView 边框的代码:

self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.cornerRadius = self.bounds.size.height/2;
self.layer.borderWidth = 0.5;

这就是它的样子:

水平部分是正确的,但有没有办法让弯曲部分“更平滑”,同时在视网膜设备上保持 1 像素线宽?它现在看起来很混叠。

谢谢!

【问题讨论】:

  • 检查cornerRadius的值,如果有小数点,渲染系统绘制不同

标签: ios uiview calayer


【解决方案1】:

您应该将self.layer.borderWidth = 0.5; 更改为self.layer.borderWidth = 1.f;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-14
    • 2016-01-20
    • 1970-01-01
    • 2017-10-26
    • 2019-11-04
    相关资源
    最近更新 更多