Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button Rotation Animation in swift to make a similar Animation [closed]

Rotate a button to make a similar animation when clicked?

image
(source: cloudfront.net)

like image 551
Omar Shiltawi Avatar asked Aug 05 '15 21:08

Omar Shiltawi


2 Answers

Swift 3:

UIView.animate(withDuration: 0.25, animations: {
    myButton.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
})

More information on rotation in Swift: Swift: How can you rotate text for UIButton and UILabel?

like image 197
Caleb Avatar answered Oct 28 '22 14:10

Caleb


You can use a regular rotation on the button:

[myButton setTransform:CGAffineTransformMakeRotation(M_PI_4)];

that would rotat + a 45degrees and make it an X :)

if you want to animate as well try

[UIView animateWithDuration:.5 animations:^{
        myButton.transform = CGAffineTransformMakeRotation(M_PI_4);
    }];
like image 43
dorian Avatar answered Oct 28 '22 12:10

dorian