[英]Getting different lines with same stroke in Core Graphics
我有一个UIView子类。
这是我重写draw方法的方法:
let path = UIBezierPath()
path.lineWidth = 1
path.move(to: CGPoint(x: rect.minX, y: rect.minY+1))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY+1))
UIColor.lightGray.setStroke()
path.stroke()
path.close()
但是,渲染视图时,线条似乎有所不同。 尤其,
当view.frame.height小于superview.frame.height时:
当view.frame.height大于superview.frame.height时:
无法弄清楚我在做什么错。
假设您的代码在draw(_ rect:CGRect)中 ,请记住rect会有所不同。 您的path.Move和path.AddLine调用均引用此内容。 您如何在超级视图中定位事物? 自动布局还是框架?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.