//
//  UIWindow+Addtions.m
//  HairKoK
//
//  Created by Jason Lee on 10/18/15.
//
//

#import "UIWindow+Addtions.h"

@implementation UIWindow (Addtions)

- (void)setRootViewController:(UIViewController *)rootViewController animated:(BOOL)animated {
    UIView *snapShotView;
    
    if (animated)
    {
        snapShotView = [self snapshotViewAfterScreenUpdates: YES];
        [rootViewController.view addSubview: snapShotView];
    }
    
    [self setRootViewController: rootViewController];
    
    if (animated)
    {
        [UIView animateWithDuration: 0.3 animations:^{
            
            snapShotView.layer.opacity = 0;
            snapShotView.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5);
            
        } completion:^(BOOL finished) {
            
            [snapShotView removeFromSuperview];
            
        }];
    }
}

@end
