我正在将 Objective-C 库 ( STKSpinnerView ) 改编为 Swift,但无法解决此错误:
func getRadius() -> CGFloat {
var r : CGRect = CGRectInset(self.bounds, self.wellThickness/2.0, self.wellThickness/2.0)
var w : CGFloat = r.size.width
var h : CGFloat = r.size.height
if w > h {
return h/2.0
}else{
return w/2.0
}
}
override func layoutSubviews() {
super.layoutSubviews()
var bounds : CGRect = self.bounds
var wt : CGFloat = self.wellThickness
var outer : CGRect = CGRectInset(self.bounds, wt/2.0, wt/2.0)
var inner : CGRect = CGRectInset(self.bounds, wt, wt)
var innerPath : UIBezierPath = UIBezierPath(ovalInRect: inner)
var arcCenter = CGPointMake(CGRectGetMidX(outer), CGRectGetMidY(outer))
var radius = self.getRadius()
var startAngle = -(CGFloat(M_PI_2))
var endAngle = (2.0 * M_PI - M_PI_2)
// (Next line) ERROR: Extra argument 'radius' in call
var outerPath : UIBezierPath = UIBezierPath(arcCenter: arcCenter, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
}
如果我使用 Apple 说的方法,我不明白为什么“半径”是一个额外的参数......你知道如何解决它吗?谢谢!