[英]How to animate transition between two views so it look like the first is going up, and the second appears from bottom?
I tried this but it's not working: 我试过了,但是没有用:
[UIView animateWithDuration:2.0
animations:^{
[self.view addSubview:theSubView];
theSubView.frame=CGRectMake(self.view.frame.origin.x, 480, self.view.frame.size.width, self.view.frame.size.height);
self.view.transform=CGAffineTransformMakeTranslation(0, -480);
theSubView.transform=CGAffineTransformMakeTranslation(0, -480);
}];
try this :- 尝试这个 :-
//First create a CATransition object to describe the transition //首先创建一个CATransition对象来描述过渡
CATransition *transition = [CATransition animation];
// Animate over 3/4 of a second
transition.duration = 1;
// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// Now to set the type of transition. Since we need to choose at random, we'll setup a couple of arrays to help us.
NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
transition.type = types[1]; // choose ur type
transition.subtype = subtypes[2]; // choose ur type
// Finally, to avoid overlapping transitions we assign ourselves as the delegate for the animation and wait for the
// -animationDidStop:finished: message. When it comes in, we will flag that we are no longer transitioning.
transitioning = YES;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.layer addAnimation:transition forKey:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.