简体   繁体   English

如何为两个视图之间的过渡设置动画,使其看起来像第一个视图向上,而第二个视图则从底部出现?

[英]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.

相关问题 如何为视图之间的过渡设置动画? - how to animate transition between views? 在第一个选项卡的两个视图之间切换时从背景中的第二个选项卡进行的视图(而不是应有的颜色) - View from the second tab in the background at transition between two views at the first tab (and not a color as is should) MultipleDetailViews - 视图之间的动画过渡 - MultipleDetailViews - Animate Transition Between Views 如何在两个视图之间的过渡中处理旧控制器? - How to dispose of old controller in a transition between two views? 对两个视图进行动画处理,例如在拨打电话时 - Animate two views like when you pass a phone call 如何从上到下为视图设置动画? - How to animate view from top to bottom? 两个UIWebViews,如何设置第二个webview,以便在单击链接时将它们发送到第一个要加载的webview? - Two UIWebViews, how to set the second webview so when links are clicked it sends them to the first webview to load? 键盘出现时如何向上移动底部textField? - How to move bottom textFields up when key board appears? 如何向上移动tableView以便从底部弹出视图,以使其不在iPhone的桌子顶部 - How to move tableView up inorder to popUp a view from bottom So that it is not on top of table in iPhone 视图之间的UIView动画过渡 - UIView animation transition between views
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM