0
votes

I got a problem with the animations from CGAffineTransform... I want to move the button and scale it up at the same time.

But if I do one animation alone everything works pretty straight forward. It scales up or moves the button by 50px.

But if I put both in the same animation its messed up. The button starts from far outside the screen to move in and doesn't scale as it should.

Also, after the movement of the button. The buttons scales up to the correct size i expected, but moves back to origin position before...

What do I miss here?

    let shape = CAShapeLayer()
    //shape.path = UIBezierPath(arcCenter: CGPoint(x: 25, y: 25), radius: 30, startAngle: 0, endAngle: .pi/2, clockwise: true).cgPath
    shape.lineWidth = 5
    shape.strokeColor = UIColor.black.cgColor
    timerButton.layer.addSublayer(shape)
    UIView.animate(withDuration: 2, animations: {
        self.timerButton.transform = CGAffineTransform(translationX: -50, y: 0)
        //self.timerButton.transform = CGAffineTransform(scaleX: 3, y: 3)
    }) { (true) in
        UIView.animate(withDuration: 1, animations: {
            self.timerButton.transform = CGAffineTransform(scaleX: 3, y: 3)
        }) { (true) in
            print("later")
        }
    }
1

1 Answers

0
votes

At completion of the transform of the x position, you need to change the constraint to make it permanent, the top constraint, after that also in the completion you need to remove the x position transformation,

If you follow these steps and after them animate your new transformation it should work