gpt4 book ai didi

ios - 使用 UIBezierPath 创建带圆弧的圆(包含图像)

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

我正在使用 SpriteKit 并尝试使用弧线实现以下效果

desired effect

我创建了三个 SKShapeNodes 并将 UIBezierPath 的 CGPath 属性分配给 SKShapeNode 的 路径属性。这是我的代码:

func createCircle(){

//container contains the SKShapeNodes
self.container = SKShapeNode()
self.container.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2)

//creating UIBezierPaths

let arc = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 100, startAngle: CGFloat(M_PI), endAngle: CGFloat(M_PI/2) , clockwise: false)
arc.flatness = 100
self.red = SKShapeNode()
self.red.lineWidth = 20
self.red.strokeColor = SKColor.redColor()
self.red.path = arc.CGPath


let arc1 = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 100, startAngle: CGFloat(M_PI/2), endAngle: CGFloat(0.0), clockwise: false)
self.blue = SKShapeNode()
self.blue.strokeColor = SKColor.whiteColor()
self.blue.lineWidth = 20
self.blue.path = arc1.CGPath


let arc2 = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 100, startAngle: 0.1, endAngle: CGFloat(3*M_PI/2), clockwise: false)
self.yellow = SKShapeNode()
self.yellow.strokeColor = SKColor.yellowColor()
self.yellow.lineWidth = 20
self.yellow.path = arc2.CGPath


//adding arcs to the container
self.container.addChild(red)
self.container.addChild(yellow)
self.container.addChild(blue)


//adding container to the GameScene
self.addChild(container)
}

在尝试了 startAngleendAngle 之后,我能够做到这一点:

this

代码输出形状与我要创建的圆不同。如何获得所需效果图像中的间隙?

最佳答案

使用 this图像作为引用我能够对 UIBezierPath arc 方法的 startAngleendAngle 进行更改 Result Image

关于ios - 使用 UIBezierPath 创建带圆弧的圆(包含图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33775094/

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