Как мы можем реализовать эффект Paper Onboarding. У меня есть один keeperview и 3viewconroller внутри этого. можем ли мы реализовать то же самое ниже?xCode Paper Эффект бортовой сети
this is snapchat chat camera moving effect
Как мы можем реализовать эффект Paper Onboarding. У меня есть один keeperview и 3viewconroller внутри этого. можем ли мы реализовать то же самое ниже?xCode Paper Эффект бортовой сети
this is snapchat chat camera moving effect
Я думаю, вы должны прочитать этот вопрос.
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 на фактическую рамку выбранной кнопки индекса. Напишите вопрос:
У меня есть код на GitHub, который выполняет аналогичную работу. Вот ссылка: https://github.com/karanthakakr04/Walkthrough-Demo.git Надеюсь, это вам понадобится. Также есть эта справочная информация, если кому-то это нужно: https://youtu.be/tNCsQe5vfRk –