-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.mm
More file actions
124 lines (80 loc) · 3.15 KB
/
ViewController.mm
File metadata and controls
124 lines (80 loc) · 3.15 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#import "ViewController.h"
#import "DragView.h"
#import "metalbiew.h"
@interface ViewController ()
@property (nonatomic, strong) metalbiew *vna;
@end
@implementation ViewController
- (instancetype)init {
if (self = [super init]) {
}
return self;
}
static BOOL MenDeal;
static BOOL init;
static ViewController *extraInfo;
+(void)load
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
extraInfo = [ViewController new];
[extraInfo tapIconView];
[extraInfo initTapGes];
});
}
-(void)initTapGes
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
tap.numberOfTapsRequired = 3; // 点击次数
tap.numberOfTouchesRequired = 3; // 手指数
[[[[UIApplication sharedApplication] windows] objectAtIndex:0].rootViewController.view addGestureRecognizer:tap];
[tap addTarget:self action:@selector(tapIconView)];
}
-(void)tapIconView
{
DragView *view = [[[[UIApplication sharedApplication] windows] objectAtIndex:0].rootViewController.view viewWithTag:100];
if (!view) {
view = [[DragView alloc] init];
view.tag = 100;
[[[[UIApplication sharedApplication] windows] objectAtIndex:0].rootViewController.view addSubview:view];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onConsoleButtonTapped:)];
tap.numberOfTapsRequired = 1;
[view addGestureRecognizer:tap];
}
if (!MenDeal) {
// 显示
view.hidden = NO;
} else {
// 隐藏
view.hidden = YES;
}
MenDeal = !MenDeal;
}
-(void)onConsoleButtonTapped:(id)sender
{
if(!init){
UIAlertController *alert =[UIAlertController alertControllerWithTitle:@"初始化" message:@"遇境点击初始化按钮" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * Default =[UIAlertAction actionWithTitle:@"初始化" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
init=!init;
if (!self->_vna) {
metalbiew *vc = [[metalbiew alloc] init];
self->_vna = vc;
}
[metalbiew showChange:true:init:init];
[[UIApplication sharedApplication].windows[0].rootViewController.view addSubview:self->_vna.view];
}];
UIAlertAction * Cancel =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//NSLog(@"点击取消");
}];
[alert addAction:Default];
[alert addAction:Cancel];
[[[[UIApplication sharedApplication] windows] objectAtIndex:0].rootViewController presentViewController:alert animated:YES completion:nil];
}else{
if (!_vna) {
metalbiew *vc = [[metalbiew alloc] init];
_vna = vc;
}
[metalbiew showChange:true:false:false];
[[UIApplication sharedApplication].windows[0].rootViewController.view addSubview:_vna.view];
}
}
@end