-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathCountlyOverlayWindow.m
More file actions
77 lines (69 loc) · 1.78 KB
/
CountlyOverlayWindow.m
File metadata and controls
77 lines (69 loc) · 1.78 KB
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
// CountlyOverlayWindow.m
//
// This code is provided under the MIT License.
//
// Please visit www.count.ly for more information.
#import "CountlyOverlayWindow.h"
#import "CountlyWebViewController.h"
#if (TARGET_OS_IOS)
@implementation CountlyOverlayWindow
- (instancetype)init
{
BOOL initialized = NO;
if (@available(iOS 13.0, *))
{
UIWindowScene *currentWindowScene = nil;
for (UIScene *s in UIApplication.sharedApplication.connectedScenes)
{
if (s.activationState == UISceneActivationStateForegroundActive && [s isKindOfClass:UIWindowScene.class])
{
currentWindowScene = (UIWindowScene *)s;
break;
}
}
if (currentWindowScene)
{
if (self = [super initWithWindowScene:currentWindowScene])
{
self.frame = currentWindowScene.coordinateSpace.bounds;
initialized = YES;
}
}
}
if (!initialized)
{
if (self = [super initWithFrame:UIScreen.mainScreen.bounds])
{
initialized = YES;
}
}
if (initialized)
{
self.windowLevel = UIWindowLevelAlert + 10;
self.backgroundColor = UIColor.clearColor;
self.hidden = YES;
}
return self;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if ([self.rootViewController isKindOfClass:CountlyWebViewController.self])
{
CountlyWebViewController *vc = (CountlyWebViewController *)self.rootViewController;
if (!vc.contentView || vc.contentView.hidden || vc.contentView.alpha < 0.01)
{
return nil;
}
if (vc.contentView)
{
CGPoint pointInContent = [self convertPoint:point toView:vc.contentView];
if (![vc.contentView pointInside:pointInContent withEvent:event])
{
return nil;
}
}
}
return [super hitTest:point withEvent:event];
}
@end
#endif