gpt4 book ai didi

ios - 如何快速制作形状

转载 作者:行者123 更新时间:2023-12-01 18:34:12 24 4
gpt4 key购买 nike

如何制作这样的形状
enter image description here

func createShape() {
bezierPath = UIBezierPath()
bezierPath.move(to: .zero)
bezierPath.addLine(to: CGPoint(x:self.frame.width , y: self.frame.origin.y))
bezierPath.addLine(to: CGPoint(x: self.frame.width, y: self.frame.height / 2))
bezierPath.addCurve(to: CGPoint(x:self.frame.width/2 , y: self.frame.height), controlPoint1: CGPoint(x: self.frame.width, y: self.frame.height / 2), controlPoint2: CGPoint(x:self.frame.width/2 + 33 , y: self.frame.height))
bezierPath.addCurve(to: CGPoint(x: 0, y: self.frame.height / 2), controlPoint1: CGPoint(x: self.frame.width/2 - 33, y:self.frame.height), controlPoint2: CGPoint(x: 0, y: self.frame.height / 2))
bezierPath.addLine(to: .zero)
bezierPath.close()
}

结果我得到了
enter image description here
你能帮助我吗?

最佳答案

阅读曲线的工作方式here

let bezierPath = UIBezierPath()
bezierPath.move(to: .zero)
bezierPath.addLine(to: CGPoint(x: 0 , y: self.frame.height/2))
bezierPath.addCurve(to: CGPoint(x:self.frame.width , y: self.frame.height / 2), controlPoint1: CGPoint(x: 0, y: (self.frame.height+self.frame.width)/2), controlPoint2: CGPoint(x: self.frame.width, y: (self.frame.height+self.frame.width)/2))
bezierPath.addLine(to: CGPoint(x: self.frame.width, y: 0))
bezierPath.addLine(to: .zero)
enter image description here

关于ios - 如何快速制作形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63449549/

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