CATransition不是来自UIView子类中的方法的动画

时间:2012-03-03 08:40:34

标签: iphone uiview core-animation caanimation catransition

我的UIView子类中有一个方法,它向CATransition添加了一个layer

- (void)animateWithDefaultTransition:(NSString *)transition duration:(CFTimeInterval)duration
{
    CATransition *animation = [CATransition animation];
    [animation setType:transition];
    [animation setDuration:duration];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
    [animation setSubtype:@"fromRight"];

    [zoomView setHidden:NO];
    [[self layer] addAnimation:animation forKey:nil];
}

我从另一个类中调用它:

[transitionView animateWithDefaultTransition:@"push" duration:1.0];

但是只显示zoomView,并且不会执行转换。

1 个答案:

答案 0 :(得分:0)

尝试UIView转换方法:

[UIView transitionWithView:containerView
       duration:0.2
       options:UIViewAnimationOptionTransitionFlipFromLeft
       animations:^{
         [fromView removeFromSuperview];
         [containerView addSubview:toView];
       }
       completion:NULL];