-(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"];
}
它不能很好地工作,它可以跳,所以我能做什么?谢谢
答案 0 :(得分:7)
你忘了在最后添加视图......
-(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];
}
你有没有理由不使用UIView动画块?这是iOS 4以来动画的推荐方法。使用UIView的transitionFromView:toView:duration:options:completion:应该适合你...
[UIView transitionFromView:aView
toView:bView
duration:0.25
options: (UIViewAnimationCurveEaseInOut | UIViewAnimationOptionTransitionCurlUp)
completion:nil];
我使用UIViewAnimationOptionTransitionCurlUp作为转换选项的示例,但您可以选择任何UIViewAnimationOption。