ответ

1

Я думаю, вы должны прочитать этот вопрос.

https://www.objc.io/issues/12-animations/custom-container-view-controller-transitions/

Поймите первые два этапа первой.

Тогда скачайте этап 3: Код термоусадочной упаковки от github. В соответствии с этим кодом замените реализацию «PrivateAnimatedTransition», наконец, следующим кодом.

@implementation PrivateAnimatedTransition 

static CGFloat const kChildViewPadding = 16; 
static CGFloat const kDamping = 0.75; 
static CGFloat const kInitialSpringVelocity = 0.5; 

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { 
    return 0.3; 
} 

/// Slide views horizontally, with a bit of space between, while fading out and in. 
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { 

    UIView *containerView = [transitionContext containerView]; 

    UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 
    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 
    //UIButton *button = fromViewController.button; 

    [containerView addSubview:toViewController.view]; 

    CGRect buttonFrame = CGRectMake(300, 450, 10, 10); 

    UIBezierPath *circleMaskPathInitial = [UIBezierPath bezierPathWithOvalInRect:buttonFrame]; 
    CGPoint extremePoint = CGPointMake(305, 455); 
    CGFloat radius = sqrt((extremePoint.x * extremePoint.x) + (extremePoint.y * extremePoint.y)); 
    UIBezierPath *circleMaskPathFinal = [UIBezierPath bezierPathWithOvalInRect:CGRectInset(buttonFrame, -radius, -radius)]; 

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
    maskLayer.path = circleMaskPathFinal.CGPath; 
    toViewController.view.layer.mask = maskLayer; 

    CABasicAnimation *maskLayerAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; 
    maskLayerAnimation.fromValue = (__bridge id _Nullable)(circleMaskPathInitial.CGPath); 
    maskLayerAnimation.toValue = (__bridge id _Nullable)(circleMaskPathFinal.CGPath); 
    maskLayerAnimation.duration = [self transitionDuration:transitionContext]; 
    [maskLayer addAnimation:maskLayerAnimation forKey:@"path"]; 

    [self performSelector:@selector(finishTransition:) withObject:transitionContext afterDelay:[self transitionDuration:transitionContext]]; 
} 

- (void)finishTransition:(id <UIViewControllerContextTransitioning>)transitionContext { 
    [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; 
    [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view.layer.mask = nil; 
} 

и "BINGO" вы сделали. Просто замените buttonFrame на фактическую рамку выбранной кнопки индекса. Напишите вопрос:

+0

У меня есть код на GitHub, который выполняет аналогичную работу. Вот ссылка: https://github.com/karanthakakr04/Walkthrough-Demo.git Надеюсь, это вам понадобится. Также есть эта справочная информация, если кому-то это нужно: https://youtu.be/tNCsQe5vfRk –

 Смежные вопросы

  • Нет связанных вопросов^_^