我有一个应用程序,我需要
使用presentmodalview类型动画
向子视图添加子视图
但是在
CATransition
我没有找到任何类型的过渡。
也在UItransitionstyle
有人可以指导我吗?
答案 0 :(得分:1)
试试此代码
[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"];
有关详细信息,请查看这些链接
答案 1 :(得分:1)
更改子视图的框架以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) {
}
];
答案 2 :(得分:1)
尝试使用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) {
}];
请在UIViewAnimationOptions
部分查看UIView class reference动画选项以及方法详情。
希望这有帮助
答案 3 :(得分:1)
我看到已经发布了许多答案。这个,如果你只想使用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"];