UIView rotates while scaling using CGAffineTransformMakeScale

Im using CGAffineTransformMakeScale to scale a UIView from 0.1 to 1.0.

The problem is that the view is also rotating while the scaling is being animated. So it ends with a scale of 1.0 AND 90ยบ of rotation.

  • How to turn the iPhone camera flash on/off?
  • How do I programmatically set the Return Key for a particular UITextField?
  • Base internationalization and multiple storyboard not working right
  • Fill master and detail view in full screen mode of iPad
  • Xcode 5 - Launch Images not loading in iPad of iPhone app
  • Is there a tool in xcode that allows me to look at the data in my xcdatamodel file
  • [self presentModalViewController:slideTwoViewController animated: NO];
    [slideTwoViewController.view setTransform:CGAffineTransformMakeScale(0.1,0.1)];
    [UIView beginAnimations: nil context: nil];
    [UIView setAnimationDuration:2.0];
    [slideTwoViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)];
    [UIView commitAnimations];

    The initial application orientation is landscape left. So when the animation ends the UIView looks like in portrait.

    Is this supposed to happen? am I missing something?


    2 Solutions Collect From Internet About “UIView rotates while scaling using CGAffineTransformMakeScale”

    My bet, is the view already have a transform set and you are overwriting it with the new transform and it is animating the difference.

    Try using the following function instead:

    CGAffineTransformScale(<#CGAffineTransform t#>, <#CGFloat sx#>, <#CGFloat sy#>)

    With this function, you pass the original transform slideTwoViewController.view.transform and your scale factor.

    slideTwoViewController.view.transform = CGAffineTransformScale(slideTwoViewController.view.transform, 0.1, 0.1);

    Despite of scaling rootview try to add subview which become your new pseudo rootview (with all the rest subviews connected underneath) and then scale pseudo rootview. This way you are avoiding any transform collisions made by system on the real rootview (e.g. autorotating) and then you can use CGAffineTransformMakeScale freely.