ja nie potrafię usunąć animację z majątku mojego CAShapeLayer strokeEnd
.mogę zmienić właściwość strokeEnd bez animacji?
Dokumentacja mówi, że nieruchomość jest animatable
ale to nie jest animowana domyślnie i nie można zidentyfikować problem. Wszelkie sugestie, gdzie szukać?
Oto mój kod:
class ViewController: UIViewController {
let circle = CAShapeLayer()
override func viewDidLoad() {
super.viewDidLoad()
// Circle
circle.fillColor = UIColor.clearColor().CGColor
circle.strokeColor = UIColor.blackColor().CGColor
circle.lineWidth = 10
circle.strokeEnd = 0
circle.lineJoin = kCALineJoinRound
circle.path = UIBezierPath(ovalInRect: CGRectMake(60, 140, 200, 200)).CGPath
circle.actions = ["strokeEnd" : NSNull()]
// Show Button
let showButton = UIButton(frame: CGRectMake(40, 40, 240, 40))
showButton.addTarget(self, action: "showButton", forControlEvents: UIControlEvents.TouchUpInside)
showButton.setTitle("Show circle", forState: UIControlState.Normal)
showButton.backgroundColor = UIColor.greenColor()
// Add to view
self.view.layer.insertSublayer(circle, atIndex: 1)
self.view.addSubview(showButton)
}
func showButton() {
circle.strokeEnd = 1
}
}
Jaki jest sens "circle.actions = [" strokeEnd ": NSNull()]'? – idmean
Widocznie CAShapeLayer posiada akcje domyślne (animacji) na jego właściwości .. – Tieme
- Usunięto rozwiązanie z pytaniem i dodaje je do poniższej odpowiedzi .. – Tieme