Ios 无法获取CAShapeLayer的正确中心
有人能指出我做错了什么吗?我需要适应所有的iphone屏幕。这是一个好方法吗Ios 无法获取CAShapeLayer的正确中心,ios,swift3,cashapelayer,Ios,Swift3,Cashapelayer,有人能指出我做错了什么吗?我需要适应所有的iphone屏幕。这是一个好方法吗 var progressCircle = CAShapeLayer() let centerPoint = CGPoint (x: vu_SubmissionViewWithImageInCenter.bounds.width / 2, y: imgVu_Submission.bounds.width / 2) let circleRadius : CGFloat = vu_SubmissionVie
var progressCircle = CAShapeLayer()
let centerPoint = CGPoint (x: vu_SubmissionViewWithImageInCenter.bounds.width / 2, y: imgVu_Submission.bounds.width / 2)
let circleRadius : CGFloat = vu_SubmissionViewWithImageInCenter.bounds.width / 2 * 0.94
let circlePath = UIBezierPath(arcCenter: centerPoint, radius: circleRadius, startAngle: CGFloat(-0.5 * M_PI), endAngle: CGFloat(1.5 * M_PI), clockwise: true )
progressCircle = CAShapeLayer ()
progressCircle.path = circlePath.cgPath
progressCircle.strokeColor = UIColor.fuschia.cgColor
progressCircle.fillColor = UIColor.clear.cgColor
progressCircle.lineWidth = 3.5
progressCircle.strokeStart = 0
progressCircle.strokeEnd = 1.0
vu_SubmissionViewWithImageInCenter.layer.addSublayer(progressCircle)
let animation = CABasicAnimation(keyPath: "strokeEnd")
animation.fromValue = 0
animation.toValue = 1.0
animation.duration = 5.0
animation.fillMode = kCAFillModeForwards
animation.isRemovedOnCompletion = false
progressCircle.add(animation, forKey: "ani")
animation.delegate = self
您的半径计算错误。计算从弧中心到imageview边的距离,并将其用作半径 您的问题中包含代码的方法是什么?@robmayoff ViewWillLayoutSubview是视图控制器视图的子视图。在IB中,我检查了两次。您是否考虑过方法名称
viewWillLayoutSubviews
与方法viewDidLayoutSubviews
相比意味着什么?问题不在于半径,而在于绘图中心