gpt4 book ai didi

ios - 无法在同一个 CGMutablePathRef 上创建两个 CGPathAddArc

转载 作者:行者123 更新时间:2023-11-28 12:52:28 24 4
gpt4 key购买 nike

我试图理解为什么我只看到我的一个 CGPathAddArc

代码:

  var r: CGRect = self.myView.bounds
var lay: CAShapeLayer = CAShapeLayer()
var path: CGMutablePathRef = CGPathCreateMutable()
CGPathAddArc(path, nil, 30, 30, 30, 0, (360 * CGFloat(M_PI))/180, true )
CGPathAddArc(path, nil, 70, 30, 30, 0, (360 * CGFloat(M_PI))/180, true )

CGPathAddRect(path, nil, r2)
CGPathAddRect(path, nil, r)
lay.path = path
lay.fillRule = kCAFillRuleEvenOdd
self.myView.layer.mask = lay

结果:

enter image description here

有什么建议吗?谢谢!

最佳答案

如果您按下命令键并单击 CGPathAddArc 函数,您将看到文档。

/* Note that using values very near 2π can be problematic. For example,
setting `startAngle' to 0, `endAngle' to 2π, and `clockwise' to true will
draw nothing. (It's easy to see this by considering, instead of 0 and 2π,
the values ε and 2π - ε, where ε is very small.) Due to round-off error,
however, it's possible that passing the value `2 * M_PI' to approximate
2π will numerically equal to 2π + δ, for some small δ; this will cause a
full circle to be drawn.

If you want a full circle to be drawn clockwise, you should set
`startAngle' to 2π, `endAngle' to 0, and `clockwise' to true. This avoids
the instability problems discussed above. */

startAngle 设置为 0,将 endAngle 设置为 2π,并将 clockwise 设置为 true什么都不画。如果你想顺时针绘制一个完整的圆,你应该设置 startAngle 为 2π,endAngle 为 0,clockwise 为 true。这样你就可以看到所有的圈子。

关于ios - 无法在同一个 CGMutablePathRef 上创建两个 CGPathAddArc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36050117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com