2013-04-24 3 views
0

Я хочу сделать пользовательский SEGUE с пульсацией переход transition.The работает, но не рябь effect.Here не мой кодCATransition не работает

- (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]; 


} 

ответ

1

rippleEffect недокументированная тип анимации, и вы не можете полагаться на он работает одинаково (или вообще) между любыми релизами iOS, как описано здесь: ripple effect animation. Я бы настоятельно предложил реализовать анимацию самостоятельно или найти альтернативу.

+0

Я меняю код на анимацию.type = kCATransitionPush; Но анимации тоже нет. –

0

Вот метод категорий, который вы можете присоединить к 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]; 
      } 
     }]; 
    } 
} 
Смежные вопросы