-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRFUIWindow.m
107 lines (87 loc) · 2.17 KB
/
RFUIWindow.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// RFUIWindow.m
// RF
//
// Created by gouzhehua on 15-1-27.
// Copyright (c) 2015年 RF. All rights reserved.
//
#import "RFUIWindow.h"
#import "RFUIKit.h"
@interface RFUIWindowController ()
@end
@interface RFUIWindow ()
@end
@implementation RFUIWindowController
- (UIStatusBarStyle)preferredStatusBarStyle
{
return [[UIApplication sharedApplication] statusBarStyle];
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationPortrait)
return UIInterfaceOrientationMaskPortrait;
else if (orientation == UIInterfaceOrientationPortraitUpsideDown)
return UIInterfaceOrientationMaskPortraitUpsideDown;
else if (orientation == UIInterfaceOrientationLandscapeLeft)
return UIInterfaceOrientationMaskLandscapeLeft;
else if (orientation == UIInterfaceOrientationLandscapeRight)
return UIInterfaceOrientationMaskLandscapeRight;
return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
return orientation;
}
- (BOOL)prefersStatusBarHidden
{
return [UIApplication sharedApplication].statusBarHidden;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
@end
@implementation RFUIWindow
- (id)init
{
self = [super initWithFrame:[UIScreen mainScreen].bounds];
if (self)
{
self.rootViewController = [[RFUIWindowController alloc] init];
[self.rootViewController.view setTapActionWithTarget:self selector:@selector(onBgClick:)];
self.rootViewController.view.userInteractionEnabled = YES;
}
return self;
}
- (void)show
{
self.frame = [UIScreen mainScreen].bounds;
self.rootViewController.view.frame = self.bounds;
self.windowLevel = UIWindowLevelStatusBar + 2;
self.hidden = NO;
[self makeKeyAndVisible];
}
- (void)dismiss
{
self.hidden = YES;
[self resignKeyWindow];
self.rootViewController = nil;
}
- (UIView *)bgView
{
return self.rootViewController.view;
}
- (void)onBgClick:(id)sender
{
if (self.bgClickBlock != nil)
{
self.bgClickBlock();
}
}
@end