-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIViewController+KVICustomLaunchScreen.m
42 lines (32 loc) · 1.24 KB
/
UIViewController+KVICustomLaunchScreen.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
//
// KVICustomLaunchScreenViewController.m
//
//
// Created by Vasyl Khmil on 9/5/15.
//
//
#import "UIViewController+KVICustomLaunchScreen.h"
#import "KVICustomLaunchScreenWindow.h"
@implementation UIViewController (KVICustomLaunchScreen)
- (void)kvi_endDispalyingAsLaunchScreenWithPreparation:(void (^)())preparation completion:(void (^)())completion {
KVICustomLaunchScreenWindow *launchScreenWindow = [self launchScreenDispayingWindow];
[launchScreenWindow endDispalyingLaunchScreenWithPreparation:preparation completion:completion];
}
#pragma mark - Private
- (KVICustomLaunchScreenWindow *)launchScreenDispayingWindow {
NSArray *windows = [UIApplication sharedApplication].windows;
__block KVICustomLaunchScreenWindow *launchScreenWindow;
[windows enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([self isSelfDisplayingLaunchScreenWindow:obj]) {
launchScreenWindow = obj;
}
}];
return launchScreenWindow;
}
- (BOOL)isSelfDisplayingLaunchScreenWindow:(UIWindow *)window {
if ([window isKindOfClass:[KVICustomLaunchScreenWindow class]]) {
return ([(KVICustomLaunchScreenWindow *)window launchScreenViewController] == self);
}
return NO;
}
@end