how does the CATransition work?

孤街浪徒 提交于 2019-11-29 12:24:52

You forgot to actually add the view at the end...

-(IBAction)jump2b:(id)sender{
    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 0.25f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;
    animation.removedOnCompletion = NO;
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromTop;
    [bView.view.layer addAnimation:animation forKey:@"animation"];

    //add bView to current view
    [self.view addSubview:bView];
}

Is there reason why you're not using UIView animation blocks? It's the recommended method for animations since iOS 4. Using UIView's transitionFromView:toView:duration:options:completion: should work for you...

[UIView transitionFromView:aView 
                    toView:bView 
                  duration:0.25 
                   options: (UIViewAnimationCurveEaseInOut | UIViewAnimationOptionTransitionCurlUp)
                completion:nil];

I used UIViewAnimationOptionTransitionCurlUp as an example for the transition option, but you can choose any UIViewAnimationOption.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!