forked from osteslag/custom-container-transitions
/
AppDelegate.m
71 lines (51 loc) · 2.57 KB
/
AppDelegate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// AppDelegate.m
// Container Transitions
//
// Created by Joachim Bondo on 30/04/2014.
// Copyright (c) 2014 Joachim Bondo. All rights reserved.
//
#import "AppDelegate.h"
#import "ContainerViewController.h"
#import "ChildViewController.h"
#import "Animator.h"
@interface AppDelegate () <ContainerViewControllerDelegate>
@property (nonatomic, strong) UIWindow *privateWindow;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.privateWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.privateWindow.rootViewController = [self _configuredRootViewController];
[self.privateWindow makeKeyAndVisible];
return YES;
}
#pragma mark - ContainerViewControllerDelegate Protocol
- (id<UIViewControllerAnimatedTransitioning>)containerViewController:(ContainerViewController *)containerViewController animationControllerForTransitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController {
return [[Animator alloc] init];
}
#pragma mark - Private Methods
- (UIViewController *)_configuredRootViewController {
NSArray *childViewControllers = [self _configuredChildViewControllers];
ContainerViewController *rootViewController = [[ContainerViewController alloc] initWithViewControllers:childViewControllers];
// rootViewController.delegate = self;
return rootViewController;
}
- (NSArray *)_configuredChildViewControllers {
// Set colors, titles and tab bar button icons which are used by the ContainerViewController class for display in its button pane.
NSMutableArray *childViewControllers = [[NSMutableArray alloc] initWithCapacity:3];
NSArray *configurations = @[
@{@"title": @"First", @"color": [UIColor colorWithRed:0.4f green:0.8f blue:1 alpha:1]},
@{@"title": @"Second", @"color": [UIColor colorWithRed:1 green:0.4f blue:0.8f alpha:1]},
@{@"title": @"Third", @"color": [UIColor colorWithRed:1 green:0.8f blue:0.4f alpha:1]},
];
for (NSDictionary *configuration in configurations) {
ChildViewController *childViewController = [[ChildViewController alloc] init];
childViewController.title = configuration[@"title"];
childViewController.themeColor = configuration[@"color"];
childViewController.tabBarItem.image = [UIImage imageNamed:configuration[@"title"]];
childViewController.tabBarItem.selectedImage = [UIImage imageNamed:[configuration[@"title"] stringByAppendingString:@" Selected"]];
[childViewControllers addObject:childViewController];
}
return childViewControllers;
}
@end