CGAffineTransformTranslate正在旋转

时间:2012-05-24 11:38:38

标签: ios core-graphics cgaffinetransform

我有一个视图控制器,在加载时应该放大视图中的特定点(然后设置缩小动画)。当它被segue推到导航堆栈的顶部时,它会非常好地显示放大区域。

但是,如果我转到我的StoryBoard并将该视图控制器设置为初始视图控制器,则在加载视图时会将其放大但旋转90度。不知道为什么。这是代码:

-(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
    ];
}

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

也许您应该使用视图中的初始变换:

   -(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
        ];
    }