我有一个我需要的应用程序
将子视图添加到具有 presentmodalview 类型动画的视图
但在
CATransition
我没有发现任何类型的过渡。也在
UItransitionstyle
有人可以指导我吗?
试试这个代码
[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"];
有关更多信息,请查看这些链接
在动画中更改子视图的框架,UIView
如下所示,
最初设置
subView.frame=CGRectMake(0,self.view.frame.size.height,your_width,your_height);
然后在动画中设置所需的帧位置
[UIView animateWithDuration:0.25 delay:0 options: UIViewAnimationCurveEaseOut animations:^ {
// set subView's frame
} completion:^(BOOL finished) {
}
];
尝试使用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.
}];
您可以根据自己的说服力更改动画持续时间。您也可以使用以下内容:
[UIView animateWithDuration:1.0 animations: {
//your Implemntation
}];
或者
[UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationCurveEaseIn animations:^{
} completion:^(BOOL finished) {
}];
请查看UIView 类参考中的动画选项UIViewAnimationOptions
部分和方法的详细信息。
如果你只想使用 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"];