coding22
coding22

Reputation: 689

How would I lower the speed of the rotation to 0 in Swift?

I have this code that rotates my imageview but when I press my pause button I want the rotation speed to be 0. How would I do that?

@IBAction func playButtonL(sender: AnyObject) {

    rotation.toValue = NSNumber(double: M_PI * 2)
    rotation.duration = 2
    rotation.cumulative = true
    rotation.repeatCount = FLT_MAX
    self.leftCircleImageView.layer.addAnimation(rotation, forKey: "rotationAnimation")
}


@IBAction func pauseButtonR(sender: AnyObject) {


}

Upvotes: 0

Views: 239

Answers (1)

Milan V.
Milan V.

Reputation: 697

To Reduce time of animation you can use

rotation.duration = 2

To stop reset it's state default you can use

cabasicanimation.removedOnCompletion = NO;

cabasicanimation.fillMode = kCAFillModeForwards;

Answer credits and reference :

CABasicAnimation resets to initial value after animation completes

Hope it helps! let me know if you need any further help.

Upvotes: 1

Related Questions