我想使一个自定义的波纹transition.The过渡工作,但没有波纹effect.Here是我的代码
- (void)perform
{
// Add your own animation code here.
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.7;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.type = @"rippleEffect";
[[[[self sourceViewController] view] layer] addAnimation:animation forKey:@"animation"];
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}发布于 2013-04-24 09:43:53
rippleEffect是一种没有文档记录的动画类型,您不能依赖它在任何特定的iOS版本之间(或者根本不能)像这里讨论的那样工作:ripple effect animation。我强烈建议你自己实现这个动画,或者找一个替代方案。
发布于 2013-04-24 11:01:58
下面是一个category方法,您可以附加到UIViewController以使用CAAnimations在父视图容器中的子视图之间进行转换。您可能需要根据自己的目的对其进行修改,但它显示了如何正确地将CATransitions用于动画。
我写这篇文章是为了在父UIViewController中创建来回分页效果,以便在子视图之间滑动。
- (void) transitionFromView:(UIView*)fromView
toView:(UIView*)toView
usingContainerView:(UIView*)container
andTransition:(NSString*)transitionType{
__block CGPoint targetOffset = fromView.center;
__block BOOL transitionFromSameView = [toView isEqual:fromView];
// In some cases, we want to perform the illusion of a transition when we are really just changing data in the same view.
// In those cases, we don't need to perform this position modification.
__block CGPoint centerOffset = fromView.center;
__block BOOL useAnimatedTransition = (transitionType != nil)?YES:NO;
__block BOOL isLeftToRight = ([transitionType isEqualToString:kCATransitionFromRight])?YES:NO;
if(transitionFromSameView == NO){
CGFloat horizontalOffset = (isLeftToRight == YES)?[toView sizeWidth] + 100:-([toView sizeWidth] + 100);
centerOffset = CGPointMake(fromView.center.x + horizontalOffset, fromView.center.y);
[toView setCenter:centerOffset];
[container insertSubview:toView belowSubview:fromView];
}
UIView *blockToView = toView;
UIView *blockFromView = fromView;
UIView *blockContainerView = container;
if(useAnimatedTransition == NO){
if(transitionFromSameView == NO){
[blockToView setCenter:targetOffset];
[blockFromView setCenter:centerOffset];
[blockFromView removeFromSuperview];
} else {
[blockToView setCenter:targetOffset];
[blockFromView setCenter:centerOffset];
}
} else {
[UIView animateWithDuration:kTransitionTime animations:^{
CATransition *animation = [CATransition animation];
[animation setDuration:kTransitionTime];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:transitionType];
[[blockContainerView layer] addAnimation:animation forKey:@"TransitionViews"];
if(transitionFromSameView == NO){
[blockToView setCenter:targetOffset];
[blockFromView setCenter:centerOffset];
}
} completion:^(BOOL finished) {
if(transitionFromSameView == NO){
[blockFromView removeFromSuperview];
}
}];
}
}https://stackoverflow.com/questions/16181799
复制相似问题