0

I had to animate few button in such a way that it looks like they are rotating onto screen from below and managed to do that. In order for the solution to work I needed to change buttons orientation on viewDidLoad like this:

for (UIButton* button in self.shareButtons) {
    button.imageView.image = [UIImage imageWithCGImage:button.imageView.image.CGImage
                                                 scale:1.0 orientation: UIImageOrientationDownMirrored];
}

It all works fine, but when a touch is catch within a button it then cancel this orientation change and button is "downmirrored" as caused by the animations.

How can I prevent/avoid it?

Thanks in advance.

Wil Shipley
  • 9,343
  • 35
  • 59
anks
  • 3
  • 1
  • Why do you think you need to change the orientation of the image? Why are you not doing this with a (affine) transform? – Wain May 07 '13 at 15:18

1 Answers1

0

try to set the image this way

[button setImage:[UIImage imageWithCGImage:button.imageView.image.CGImage
                 scale:1.0 orientation: UIImageOrientationDownMirrored]
                 forState:UIControlStateNormal];

also have a look at my other answer for rotating images

as mentioned in comments Applying transform is also a good option

button.transform = CGAffineTransformMakeRotation( ( 180 * M_PI ) / 180 );

will rotate the UIButton 180 degrees.

Community
  • 1
  • 1
Bonnie
  • 4,943
  • 30
  • 34