Eric
Eric

Reputation: 16921

CGAffineTransformTranslate is rotating

I have a view controller which upon loading should be zoomed in at a particular point in the view (to then animate a zoom out). When it's pushed to the top of the navigation stack by a segue, it displays the zoomed in area very well.

However if I go to my StoryBoard and set that view controller as the initial view controller, upon loading the view is zoomed in but rotated 90 degrees. No clue why. Here is the code:

-(void)viewDidAppear:(BOOL)animated
{        
    //INITIAL TRANSFORM
    CGAffineTransform t1 = CGAffineTransformMakeTranslation(-50, 0); 
    CGAffineTransform t2 = CGAffineTransformTranslate(t1, 0, 250);
    CGAffineTransform t3 = CGAffineTransformScale(t2, 1.7, 1.7);
    self.view.transform = t3;

    //ZOOM OUT
    [UIView animateWithDuration:8
                          delay:1.5
                        options:UIViewAnimationCurveEaseOut animations:^{
                           // self.view.transform = CGAffineTransformIdentity;
                        }completion:nil
    ];
}

Any thoughts?

Upvotes: 0

Views: 1319

Answers (1)

CarlJ
CarlJ

Reputation: 9481

Maybe you should use the initial transform from the view:

   -(void)viewDidAppear:(BOOL)animated
    {        
        //INITIAL TRANSFORM
        CGAffineTransform t0 = self.view.transform;
        CGAffineTransform t1 = CGAffineTransformTranslate(t0, -50, 0); 
        CGAffineTransform t2 = CGAffineTransformTranslate(t1, 0, 250);
        CGAffineTransform t3 = CGAffineTransformScale(t2, 1.7, 1.7);
        self.view.transform = t3;

        //ZOOM OUT
        [UIView animateWithDuration:8
                              delay:1.5
                            options:UIViewAnimationCurveEaseOut animations:^{
                               // self.view.transform = CGAffineTransformIdentity;
                            }completion:nil
        ];
    }

Upvotes: 1

Related Questions