Держите первый контроллер представления видимым в пользовательском переходе

У меня есть три контроллера представления, которые устроены как Snapchat. Основной встроен в UINavigationController и находится посередине с контроллером представления слева и одним справа. Переход работает хорошо, анимация влево/вправо. Но в Snapchat, когда вы переключаетесь на контроллер рядом с камерой или наоборот, камера останется видимой (не окрашенной в черный цвет) в пользовательском переходе. С МОЙ, если я помещаю второй контроллер представления в стек, первый контроллер представления, кажется, исчезает до черного цвета, поскольку анимация начинается, когда я хочу, чтобы он оставался полностью видимым. Я предполагаю, что мне нужно что-то изменить в моем пользовательском переходе.

 @implementation toTheRight

- (void) perform{
UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *)self.destinationViewController;

CATransition *transition = [CATransition animation];
transition.duration = .5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;

[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
}

person Peter    schedule 19.05.2015    source источник


Ответы (1)


Взято из этих двух проектов, а затем изменено CustomSegue и CustomUnwindSegue в качестве примера. https://github.com/soleares/SOLPresentingFun https://github.com/Phillipus/CustomSegue

CustomSegue.m

#import "CustomSegue.h"
#import "SOLSlideTransitionAnimator.h"

@interface CustomSegue()<UIViewControllerTransitioningDelegate>
@property (nonatomic,strong) SOLSlideTransitionAnimator* animator;
@end

@implementation CustomSegue

- (void)perform {
    UIViewController *sourceViewController = self.sourceViewController;
    UIViewController *destinationViewController = self.destinationViewController;

    destinationViewController.transitioningDelegate = self;
    destinationViewController.modalPresentationStyle = UIModalPresentationCustom;

    [sourceViewController presentViewController:destinationViewController animated:YES completion:nil];
}

/*
 Called when presenting a view controller that has a transitioningDelegate
 */
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting
                                                                      sourceController:(UIViewController *)source
{
    self.animator.appearing = YES;
    return self.animator;
}

-(SOLSlideTransitionAnimator*) animator
{
    if(!_animator)
    {
        _animator = [[SOLSlideTransitionAnimator alloc] init];
        _animator.appearing = NO;
        _animator.duration = 0.35;
        _animator.edge = SOLEdgeRight;
    }
    return _animator;
}

@end

CustomUnwindSegue.m

@interface CustomUnwindSegue()<UIViewControllerTransitioningDelegate>
@property (nonatomic,strong) SOLSlideTransitionAnimator* animator;
@end



#import "CustomUnwindSegue.h"
#import "SOLSlideTransitionAnimator.h"

@implementation CustomUnwindSegue

- (void)perform {
    UIViewController *sourceViewController = self.sourceViewController;

    sourceViewController.transitioningDelegate = self;
    sourceViewController.modalPresentationStyle = UIModalPresentationCustom;

    [sourceViewController dismissViewControllerAnimated:YES completion:nil];
}

-(SOLSlideTransitionAnimator*) animator
{
    if(!_animator)
    {
        _animator = [[SOLSlideTransitionAnimator alloc] init];
        _animator.appearing = NO;
        _animator.duration = 0.35;
        _animator.edge = SOLEdgeRight;
    }
    return _animator;
}

/*
 Called when dismissing a view controller that has a transitioningDelegate
 */
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    self.animator.appearing = NO;
    return self.animator;
}

@end
person user1036272    schedule 16.07.2015