gpt4 book ai didi

Swift 3 'CGContextAddArc' 不可用 : Use addArc(center:radius:startAngle:endAngle:clockwise:)

转载 作者:可可西里 更新时间:2023-11-01 00:41:49 25 4
gpt4 key购买 nike

我这里有这行代码:

CGContextAddArc(context, (round(frame.size.width))/(2 * (appDelegate.webview?.scrollView.zoomScale)!), round(frame.size.height)/(2 * (appDelegate.webview?.scrollView.zoomScale)!), (round(frame.size.width) - 10)/(2 * (appDelegate.webview?.scrollView.zoomScale)!), 0.0, CGFloat(M_PI * 2.0), 1)

但是你现在得到这个错误:

'CGContextAddArc' is unavailable: Use addArc(center:radius:startAngle:endAngle:clockwise:)

所以我尝试使用 addArc 但是当我开始输入它时,该方法没有出现,如何调用 addArc?

这是我的完整代码:

func drawCircle()
{
// Get the Graphics Context
let context = UIGraphicsGetCurrentContext();

// Set the circle outerline-width
context?.setLineWidth(5.0);

// Set the circle outerline-colour
UIColor.red.set()

// Create Circle
CGContextAddArc(context, (round(frame.size.width))/(2 * (appDelegate.webview?.scrollView.zoomScale)!), round(frame.size.height)/(2 * (appDelegate.webview?.scrollView.zoomScale)!), (round(frame.size.width) - 10)/(2 * (appDelegate.webview?.scrollView.zoomScale)!), 0.0, CGFloat(M_PI * 2.0), 1)

// Draw
context?.strokePath();
}

最佳答案

let center = CGPoint(x:(round(frame.size.width))/(2 * (appDelegate.webview?.scrollView.zoomScale)!), y:round(frame.size.height)/(2 * (appDelegate.webview?.scrollView.zoomScale)!))
let radius = (round(frame.size.width) - 10)/(2 * (appDelegate.webview?.scrollView.zoomScale)!)

context.addArc(center: center, radius: radius, startAngle: 0, endAngle: CGFloat(M_PI * 2.0), clockwise: true)

关于Swift 3 'CGContextAddArc' 不可用 : Use addArc(center:radius:startAngle:endAngle:clockwise:),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42617073/

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