Так что у меня есть этот хороший подкласс, который может быть изменен в какой-то момент, и затем я вызываю updateFrame (). Изменение lineWidth на любое значение приведет к сбою.То, что мне нужно, - это возможность изменять lineWidth без анимации (мгновенно).
https://cdn1.imggmi.com/uploads/2019/1/24/a93765689e524d45116f942ce734275e-full.png
https://cdn1.imggmi.com/uploads/2019/1/24/12a880d41cff1f69ef6bd2f974033627-full.png
class OvalLayer: CAShapeLayer {
func updateFrame(_ with: CGRect) {
let newFrame = with.insetBy(dx: frame.size.width * 0.07, dy: frame.size.height * 0.07)
path = UIBezierPath(ovalIn: newFrame).cgPath
lineWidth = (min(frame.size.width, frame.size.height) / 50) //if i remove this line it will be ok
}
init(frame: CGRect) {
super.init()
self.frame = frame
let newFrame = frame.insetBy(dx: frame.size.width * 0.07, dy: frame.size.height * 0.07)
lineWidth = (min(frame.size.width, frame.size.height) / 50)
strokeColor = UIColor.white.cgColor
fillColor = UIColor.clear.cgColor
path = UIBezierPath(ovalIn: newFrame).cgPath
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}