[英]How to add a subview with a presentmodalview type animation?
I have an application in which I need to我有一个应用程序,我需要
add a subview to a view with presentmodalview type animation将子视图添加到具有presentmodalview 类型动画的视图
But in但在
CATransition CATransition
I didn't find any type of transition like that.我没有找到任何类型的过渡。 Also in也在
UItransitionstyle界面过渡风格
Can anybody guide me on this?有人可以指导我吗?
Try this code试试这个代码
[self.view bringSubviewToFront:yoursubview];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[animation setDuration:1.00];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseIn]];
[yoursubview.layer addAnimation:animation forKey:@"fadeTransition"];
For more info check these links有关更多信息,请查看这些链接
Change the frame of the subview insite the UIView
Animation, like as follows,在UIView
动画中更改子视图的框架,如下所示,
initially set the最初设置
subView.frame=CGRectMake(0,self.view.frame.size.height,your_width,your_height);
then set the required frame position inside the animation然后在动画中设置所需的帧位置
[UIView animateWithDuration:0.25 delay:0 options: UIViewAnimationCurveEaseOut animations:^ {
// set subView's frame
} completion:^(BOOL finished) {
}
];
Try to use UIView
animation block:尝试使用UIView
动画块:
yourView.frame = CGRectMake(0, yourSuperView.frame.size.height, yourView.frame.size.width, yourView.frame.size.height);
[yourSuperView addSubview:yourView];
[UIView animateWithDuration:1.0 animations:^{
yourView.frame = CGRectMake(0, 0, yourView.frame.size.width, yourView.frame.size.height);
} completion:^(BOOL finished) {
//Task to do on Animation completion.
}];
You change the animation duration according to your convince.您可以根据自己的说服力更改动画持续时间。 Also you can use following:您也可以使用以下内容:
[UIView animateWithDuration:1.0 animations: {
//your Implemntation
}];
or或者
[UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationCurveEaseIn animations:^{
} completion:^(BOOL finished) {
}];
Please check the UIView class reference for animation option in UIViewAnimationOptions
section and detail of methods.请检查UIViewAnimationOptions
部分中动画选项的UIView 类参考和方法的详细信息。
If you only want to use CATransition如果您只想使用 CATransition
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromTop];
[animation setDuration:0.6f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[subview.layer addAnimation:animation forKey:@"someTransition"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.