【问题标题】:CATransition not animating from method inside UIView subclassCATransition 没有从 UIView 子类中的方法设置动画
【发布时间】:2012-03-21 15:07:50
【问题描述】:

我的 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 只是出现并且没有执行转换。

【问题讨论】:

    标签: iphone uiview core-animation caanimation catransition


    【解决方案1】:

    尝试UIView 转换方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-31
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      相关资源
      最近更新 更多