Browse Source

新增截屏类插件

liufl5 5 years ago
parent
commit
9748a627b3

+ 14 - 6
IPUMobileFunc/IPUMobileFunc.xcodeproj/project.pbxproj

@ -7,8 +7,10 @@
7 7
	objects = {
8 8
9 9
/* Begin PBXBuildFile section */
10
		045994D124247BBF0002F4A3 /* IPUScreenCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 045994CF24247BBF0002F4A3 /* IPUScreenCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
11
		045994D224247BBF0002F4A3 /* IPUScreenCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 045994D024247BBF0002F4A3 /* IPUScreenCapture.m */; };
10 12
		04C30B9B22E6ADF200BA7B68 /* IPUTipsHUDPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 04C30B9922E6ADF200BA7B68 /* IPUTipsHUDPlugin.m */; };
11
		04C30B9C22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */; };
13
		04C30B9C22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
12 14
		B20C89662397AFF900471783 /* IPUVideoRecordPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = B20C89642397AFF900471783 /* IPUVideoRecordPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
13 15
		B20C89672397AFF900471783 /* IPUVideoRecordPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = B20C89652397AFF900471783 /* IPUVideoRecordPlugin.m */; };
14 16
		B2445C7A21F17374007AB82E /* IPUUploadDownloadPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = B2445C7821F17374007AB82E /* IPUUploadDownloadPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -21,9 +23,9 @@
21 23
		B256EE2721F079F10096C446 /* IPUMobileFunc.h in Headers */ = {isa = PBXBuildFile; fileRef = B256EE2521F079F10096C446 /* IPUMobileFunc.h */; settings = {ATTRIBUTES = (Public, ); }; };
22 24
		B264A22B22B33EB200714D0D /* IPUDatabaseUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B264A22922B33EB200714D0D /* IPUDatabaseUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };
23 25
		B264A22C22B33EB200714D0D /* IPUDatabaseUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B264A22A22B33EB200714D0D /* IPUDatabaseUtil.m */; };
24
		B26A208523CC609800844692 /* IPUImageCompress.h in Headers */ = {isa = PBXBuildFile; fileRef = B26A208323CC609800844692 /* IPUImageCompress.h */; };
26
		B26A208523CC609800844692 /* IPUImageCompress.h in Headers */ = {isa = PBXBuildFile; fileRef = B26A208323CC609800844692 /* IPUImageCompress.h */; settings = {ATTRIBUTES = (Public, ); }; };
25 27
		B26A208623CC609800844692 /* IPUImageCompress.m in Sources */ = {isa = PBXBuildFile; fileRef = B26A208423CC609800844692 /* IPUImageCompress.m */; };
26
		B26A20A023CD9E0200844692 /* UIImage+IPUCompress.h in Headers */ = {isa = PBXBuildFile; fileRef = B26A209E23CD9E0200844692 /* UIImage+IPUCompress.h */; };
28
		B26A20A023CD9E0200844692 /* UIImage+IPUCompress.h in Headers */ = {isa = PBXBuildFile; fileRef = B26A209E23CD9E0200844692 /* UIImage+IPUCompress.h */; settings = {ATTRIBUTES = (Public, ); }; };
27 29
		B26A20A123CD9E0200844692 /* UIImage+IPUCompress.m in Sources */ = {isa = PBXBuildFile; fileRef = B26A209F23CD9E0200844692 /* UIImage+IPUCompress.m */; };
28 30
		B26B106C23C81C58007B13FA /* IPUDatePlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = B26B106A23C81C58007B13FA /* IPUDatePlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
29 31
		B26B106D23C81C58007B13FA /* IPUDatePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = B26B106B23C81C58007B13FA /* IPUDatePlugin.m */; };
@ -95,6 +97,8 @@
95 97
/* End PBXBuildFile section */
96 98
97 99
/* Begin PBXFileReference section */
100
		045994CF24247BBF0002F4A3 /* IPUScreenCapture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPUScreenCapture.h; sourceTree = "<group>"; };
101
		045994D024247BBF0002F4A3 /* IPUScreenCapture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IPUScreenCapture.m; sourceTree = "<group>"; };
98 102
		04C30B9922E6ADF200BA7B68 /* IPUTipsHUDPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUTipsHUDPlugin.m; sourceTree = "<group>"; };
99 103
		04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUTipsHUDPlugin.h; sourceTree = "<group>"; };
100 104
		B20C89642397AFF900471783 /* IPUVideoRecordPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPUVideoRecordPlugin.h; sourceTree = "<group>"; };
@ -283,6 +287,8 @@
283 287
				B2D5191C23B5ADE1008086A7 /* IPUBMapPlugin.m */,
284 288
				B26B106A23C81C58007B13FA /* IPUDatePlugin.h */,
285 289
				B26B106B23C81C58007B13FA /* IPUDatePlugin.m */,
290
				045994CF24247BBF0002F4A3 /* IPUScreenCapture.h */,
291
				045994D024247BBF0002F4A3 /* IPUScreenCapture.m */,
286 292
			);
287 293
			path = IPUMobileFunc;
288 294
			sourceTree = "<group>";
@ -355,13 +361,16 @@
355 361
			isa = PBXHeadersBuildPhase;
356 362
			buildActionMask = 2147483647;
357 363
			files = (
364
				B26A20A023CD9E0200844692 /* UIImage+IPUCompress.h in Headers */,
365
				045994D124247BBF0002F4A3 /* IPUScreenCapture.h in Headers */,
366
				04C30B9C22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h in Headers */,
367
				B26A208523CC609800844692 /* IPUImageCompress.h in Headers */,
358 368
				B2C7AB5D22C9926A00679075 /* IPUAudioUtil.h in Headers */,
359 369
				B28E567021F1870B00422D15 /* IPUAFNetworkingUtil.h in Headers */,
360 370
				B281A32A22CB3C6300D69B25 /* IPUFilesUtil.h in Headers */,
361 371
				B2EB0F2123A7287E00EBB34D /* IPUAMapPlugin.h in Headers */,
362 372
				B28E569E21F1B02000422D15 /* IPUResourceVersionPlugin.h in Headers */,
363 373
				B28E56C221F1BBA800422D15 /* IPUStoragePlugin.h in Headers */,
364
				B26A20A023CD9E0200844692 /* UIImage+IPUCompress.h in Headers */,
365 374
				B28E567A21F18C1C00422D15 /* UIImage+Rotate.h in Headers */,
366 375
				B28E568E21F1A8F500422D15 /* IPUCameraPlugin.h in Headers */,
367 376
				B28E56BA21F1BAB800422D15 /* IPULocationPlugin.h in Headers */,
@ -383,7 +392,6 @@
383 392
				B2D71A2C22A66D2500604504 /* IPUEmailUtil.h in Headers */,
384 393
				B2464E8422CF25E9002A159E /* IPUSystemLocationUtil.h in Headers */,
385 394
				B2BD2B7822B378C40082FCA3 /* IPUContactsUtil.h in Headers */,
386
				04C30B9C22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h in Headers */,
387 395
				B2EE784822D2D25A00E2C466 /* IPUStorageUtil.h in Headers */,
388 396
				B28E56C621F1BCCA00422D15 /* IPUMobileUIPlugin.h in Headers */,
389 397
				B28E569A21F1AE0600422D15 /* IPUImageCachePlugin.h in Headers */,
@ -393,7 +401,6 @@
393 401
				B28E56AA21F1B3CE00422D15 /* IPUAudioPlugin.h in Headers */,
394 402
				B256EE2721F079F10096C446 /* IPUMobileFunc.h in Headers */,
395 403
				B20C89662397AFF900471783 /* IPUVideoRecordPlugin.h in Headers */,
396
				B26A208523CC609800844692 /* IPUImageCompress.h in Headers */,
397 404
				B2445C7A21F17374007AB82E /* IPUUploadDownloadPlugin.h in Headers */,
398 405
				B2EB0F2023A7287E00EBB34D /* IPUSocialPlugin.h in Headers */,
399 406
			);
@ -474,6 +481,7 @@
474 481
				B28E569B21F1AE0600422D15 /* IPUImageCachePlugin.m in Sources */,
475 482
				B281A33822CC815E00D69B25 /* IPUUploadDownloadPlugin.m in Sources */,
476 483
				B28E56BB21F1BAB800422D15 /* IPULocationPlugin.m in Sources */,
484
				045994D224247BBF0002F4A3 /* IPUScreenCapture.m in Sources */,
477 485
				B26A20A123CD9E0200844692 /* UIImage+IPUCompress.m in Sources */,
478 486
				B281A33B22CC85B600D69B25 /* IPUAudioPlugin.m in Sources */,
479 487
				B28E568721F1A76E00422D15 /* IPUCustomCameraPlugin.m in Sources */,

BIN
IPUMobileFunc/IPUMobileFunc.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate


+ 34 - 0
IPUMobileFunc/IPUMobileFunc/IPUScreenCapture.h

@ -0,0 +1,34 @@
1
//
2
//  IPUScreenCapture.h
3
//  IPUMobileFunc
4
//
5
//  Created by Mac on 2020/3/20.
6
//  Copyright © 2020 Asiainfo. All rights reserved.
7
//
8
9
#import <IPUMobile/IPUMobile.h>
10
11
@interface IPUScreenCapture : IPUPlugin
12
13
/*
14
 全屏截屏
15
 参数1:0-文件路径,1-base64编码
16
 */
17
-(void)fullScreenCapture:(NSArray *)params;
18
/*
19
 无状态栏截屏
20
 参数1:0-文件路径,1-base64编码
21
 */
22
-(void)noStatusScreenCapture:(NSArray *)params;
23
/*
24
 手动截屏
25
 参数1:0-文件路径,1-base64编码
26
 */
27
-(void)handMovementScreenCapture:(NSArray *)params;
28
/*
29
 webview长图截屏
30
 参数1:0-文件路径,1-base64编码
31
 */
32
-(void)webviewScreenCapture:(NSArray *)params;
33
34
@end

+ 360 - 0
IPUMobileFunc/IPUMobileFunc/IPUScreenCapture.m

@ -0,0 +1,360 @@
1
//
2
//  IPUScreenCapture.m
3
//  IPUMobileFunc
4
//
5
//  Created by Mac on 2020/3/20.
6
//  Copyright © 2020 Asiainfo. All rights reserved.
7
//
8
9
#import "IPUScreenCapture.h"
10
11
@interface IPUScreenCapture()
12
{
13
    BOOL base64;
14
}
15
16
@property(nonatomic,weak)UIView *clipLeftView;
17
@property(nonatomic,weak)UIView *clipRightView;
18
@property(nonatomic,weak)UIView *clipTopView;
19
@property(nonatomic,weak)UIView *clipBottomView;
20
@property(nonatomic,weak)UIView *clipView;
21
@property (nonatomic, assign) CGPoint startPoint;
22
23
@end
24
25
@implementation IPUScreenCapture
26
27
28
29
/*
30
 全屏截屏
31
 参数1:0-文件路径,1-base64编码
32
 */
33
-(void)fullScreenCapture:(NSArray *)params{
34
    if (params.count>0 && params[0]!=[NSNull null]) {
35
        if ([params[0] integerValue]==0) {
36
            base64 = NO;
37
        }else{
38
            base64 = YES;
39
        }
40
    }else{
41
        base64 = NO;
42
    }
43
    UIImage *image = [self screenFullShot];
44
    NSString* path = [IPUUtility createDirInDocument:@"images" withFileName:nil withPathExtension:@"jpg"];
45
    NSData * data = UIImageJPEGRepresentation(image, 1.0);
46
    [data writeToFile:path atomically:YES];
47
    if (base64) {
48
        [self callback:[self base64EncodingWithData:data]];
49
    }else{
50
        [self callback:path];
51
    }
52
}
53
/*
54
 无状态栏截屏
55
 参数1:0-文件路径,1-base64编码
56
 */
57
-(void)noStatusScreenCapture:(NSArray *)params{
58
    if (params.count>0 && params[0]!=[NSNull null]) {
59
        if ([params[0] integerValue]==0) {
60
            base64 = NO;
61
        }else{
62
            base64 = YES;
63
        }
64
    }else{
65
        base64 = NO;
66
    }
67
    UIImage *image = [self screenNoStatusShot];
68
    NSString* path = [IPUUtility createDirInDocument:@"images" withFileName:nil withPathExtension:@"jpg"];
69
    NSData * data = UIImageJPEGRepresentation(image, 1.0);
70
    [data writeToFile:path atomically:YES];
71
    if (base64) {
72
        [self callback:[self base64EncodingWithData:data]];
73
    }else{
74
        [self callback:path];
75
    }
76
}
77
/*
78
 手动截屏
79
 参数1:0-文件路径,1-base64编码
80
 */
81
-(void)handMovementScreenCapture:(NSArray *)params{
82
    if (params.count>0 && params[0]!=[NSNull null]) {
83
        if ([params[0] integerValue]==0) {
84
            base64 = NO;
85
        }else{
86
            base64 = YES;
87
        }
88
    }else{
89
        base64 = NO;
90
    }
91
    [self addPanGesture];
92
}
93
/*
94
 webview长图截屏
95
 参数1:0-文件路径,1-base64编码
96
 */
97
-(void)webviewScreenCapture:(NSArray *)params{
98
    if (params.count>0 && params[0]!=[NSNull null]) {
99
        if ([params[0] integerValue]==0) {
100
            base64 = NO;
101
        }else{
102
            base64 = YES;
103
        }
104
    }else{
105
        base64 = NO;
106
    }
107
    UIImage *image = [self screenWebviewShot];
108
    NSString* path = [IPUUtility createDirInDocument:@"images" withFileName:nil withPathExtension:@"jpg"];
109
    NSData * data = UIImageJPEGRepresentation(image, 1.0);
110
    [data writeToFile:path atomically:YES];
111
    if (base64) {
112
        [self callback:[self base64EncodingWithData:data]];
113
    }else{
114
        [self callback:path];
115
    }
116
}
117
#pragma mark - 内部调用方法
118
/*
119
 全屏截图
120
 */
121
- (UIImage *)screenFullShot {
122
    UIViewController *vc = [self getViewController];
123
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT), NO, 0.0);
124
    [vc.view.layer renderInContext:UIGraphicsGetCurrentContext()];
125
    UIImage *screenShotImage = UIGraphicsGetImageFromCurrentImageContext();
126
    UIGraphicsEndImageContext();
127
    return screenShotImage;
128
}
129
/*
130
 无状态栏截图
131
 */
132
- (UIImage *)screenNoStatusShot {
133
    IPUMobileWebView *webview = [self getWebView];
134
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT), NO, 0.0);
135
    [webview.layer renderInContext:UIGraphicsGetCurrentContext()];
136
    UIImage *screenShotImage = UIGraphicsGetImageFromCurrentImageContext();
137
    UIGraphicsEndImageContext();
138
    return screenShotImage;
139
}
140
/*
141
 *  获取当前加载的网页的截图
142
 *  获取当前WebView的size,然后一屏一屏的截图后,再拼接成一张完整的图片
143
 */
144
- (UIImage *)screenWebviewShot
145
{
146
    IPUMobileWebView *webview = [self getWebView];
147
    // 1.获取WebView的宽高
148
    CGSize boundsSize = webview.bounds.size;
149
    CGFloat boundsWidth = boundsSize.width;
150
    CGFloat boundsHeight = boundsSize.height;
151
    
152
    // 2.获取contentSize
153
    CGSize contentSize = webview.scrollView.contentSize;
154
    CGFloat contentHeight = contentSize.height;
155
    // 3.保存原始偏移量,便于截图后复位
156
    CGPoint offset = webview.scrollView.contentOffset;
157
    // 4.设置最初的偏移量为(0,0);
158
    [webview.scrollView setContentOffset:CGPointMake(0, 0)];
159
    
160
    NSMutableArray *images = [NSMutableArray array];
161
    while (contentHeight > 0) {
162
        // 5.获取CGContext
163
        UIGraphicsBeginImageContextWithOptions(boundsSize, NO, 0.0);
164
        CGContextRef ctx = UIGraphicsGetCurrentContext();
165
        // 6.渲染要截取的区域
166
        [webview.layer renderInContext:ctx];
167
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
168
        UIGraphicsEndImageContext();
169
        // 7.截取的图片保存起来
170
        [images addObject:image];
171
        
172
        CGFloat offsetY = webview.scrollView.contentOffset.y;
173
        [webview.scrollView setContentOffset:CGPointMake(0, offsetY + boundsHeight)];
174
        contentHeight -= boundsHeight;
175
    }
176
    // 8 webView 恢复到之前的显示区域
177
    [webview.scrollView setContentOffset:offset];
178
    
179
    CGFloat scale = [UIScreen mainScreen].scale;
180
    
181
    CGSize imageSize = CGSizeMake(contentSize.width * scale,
182
                                  contentSize.height * scale);
183
    // 9.根据设备的分辨率重新绘制、拼接成完整清晰图片
184
    UIGraphicsBeginImageContext(imageSize);
185
    [images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) {
186
        [image drawInRect:CGRectMake(0,
187
                                     scale * boundsHeight * idx,
188
                                     scale * boundsWidth,
189
                                     scale * boundsHeight)];
190
    }];
191
    
192
    UIImage *fullImage = UIGraphicsGetImageFromCurrentImageContext();
193
    UIGraphicsEndImageContext();
194
    return fullImage;
195
}
196
#pragma mark - base64类型图片数据
197
-(NSString*) base64EncodingWithPath:(NSString*) filePath{
198
    UIImage* image = [UIImage imageWithContentsOfFile:filePath];
199
    if (image) {
200
        NSData* data =  UIImageJPEGRepresentation(image, 1.0);
201
        NSString *base64 = [data base64EncodedStringWithOptions:0];
202
        return base64;
203
    }
204
    return nil;
205
}
206
-(NSString*) base64EncodingWithData:(NSData*) data{
207
    if (data) {
208
        NSString *base64 = [data base64EncodedStringWithOptions:0];
209
        return base64;
210
    }
211
    return nil;
212
}
213
#pragma mark - 手动截图(内部调用)
214
/*
215
 手动截图
216
 */
217
-(void)addPanGesture{
218
    UIViewController *vc = [self getViewController];
219
    self.clipLeftView.frame = vc.view.frame;
220
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
221
    [vc.view addGestureRecognizer:pan];
222
}
223
- (void)pan:(UIPanGestureRecognizer *)pan
224
{
225
    UIViewController *vc = [self getViewController];
226
    CGPoint endPoint = CGPointZero;
227
    if (pan.state == UIGestureRecognizerStateBegan)
228
    {
229
        /**开始点击时,记录手势的起点**/
230
        self.startPoint = [pan locationInView:vc.view];
231
    }
232
    else if(pan.state == UIGestureRecognizerStateChanged)
233
    {
234
        /**当手势移动时,动态改变终点的值,并计算起点与终点之间的矩形区域**/
235
        endPoint = [pan locationInView:vc.view];
236
        //计算矩形区域的宽高
237
        CGFloat w = endPoint.x - self.startPoint.x;
238
        CGFloat h = endPoint.y - self.startPoint.y;
239
        //计算矩形区域的frame
240
        CGRect clipRect = CGRectMake(self.startPoint.x, self.startPoint.y, w, h);
241
        //设置剪切区域的frame
242
        self.clipView.frame = clipRect;
243
        self.clipLeftView.frame = CGRectMake(0, self.startPoint.y, self.clipView.left, self.clipView.height);
244
        self.clipRightView.frame = CGRectMake(self.clipView.right, self.startPoint.y, SCREEN_WIDTH-self.clipView.right, self.clipView.height);
245
        self.clipTopView.frame = CGRectMake(0, 0, SCREEN_WIDTH, self.clipView.top);
246
        self.clipBottomView.frame = CGRectMake(0, self.clipView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.clipView.bottom);
247
    }
248
    else if(pan.state == UIGestureRecognizerStateEnded)
249
    {
250
        UIViewController *vc = [self getViewController];
251
        UIGraphicsBeginImageContextWithOptions(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT), NO, 0.0);
252
        [vc.view.layer renderInContext:UIGraphicsGetCurrentContext()];
253
        UIImage *screenShotImage = UIGraphicsGetImageFromCurrentImageContext();
254
        UIGraphicsEndImageContext();
255
        //设置想要截图的区域
256
        CGImageRef imageRef = screenShotImage.CGImage;
257
        float px = CGImageGetWidth(imageRef)/SCREEN_WIDTH;//计算像素宽与屏幕宽的比例
258
        CGRect pxrect =  CGRectMake(self.clipView.left*px, self.clipView.top*px, self.clipView.width*px, self.clipView.height*px);
259
        CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, pxrect);
260
        UIImage *clipeImage = [[UIImage alloc] initWithCGImage:imageRefRect];
261
        //保存截图至本地,并callback本地路径给js
262
        NSString* path = [IPUUtility createDirInDocument:@"images" withFileName:nil withPathExtension:@"jpg"];
263
        NSData * data = UIImageJPEGRepresentation(clipeImage, 1.0);
264
        [data writeToFile:path atomically:YES];
265
        if (base64) {
266
            [self callback:[self base64EncodingWithData:data]];
267
        }else{
268
            [self callback:path];
269
        }
270
        //移除剪切区域视图控件,并清空
271
        [self.clipView removeFromSuperview];
272
        [self.clipBottomView removeFromSuperview];
273
        [self.clipTopView removeFromSuperview];
274
        [self.clipRightView removeFromSuperview];
275
        [self.clipLeftView removeFromSuperview];
276
        self.clipView = nil;
277
        self.clipBottomView = nil;
278
        self.clipTopView = nil;
279
        self.clipRightView = nil;
280
        self.clipLeftView = nil;
281
        //移除手势
282
        [vc.view removeGestureRecognizer:pan];
283
    }
284
}
285
-(UIView *)clipView{
286
    if (_clipView==nil) {
287
        UIView *view = [[UIView alloc] init];
288
        _clipView = view;
289
        UIViewController *vc = [self getViewController];
290
        [vc.view addSubview:_clipView];
291
    }
292
    return _clipView;
293
}
294
-(UIView *)clipLeftView{
295
    if (_clipLeftView==nil) {
296
        UIView *view = [[UIView alloc] init];
297
        _clipLeftView = view;
298
        view.backgroundColor = [UIColor blackColor];
299
        view.alpha = 0.5;
300
        UIViewController *vc = [self getViewController];
301
        [vc.view addSubview:_clipLeftView];
302
    }
303
    return _clipLeftView;
304
}
305
306
-(UIView *)clipRightView{
307
    if (_clipRightView==nil) {
308
        UIView *view = [[UIView alloc] init];
309
        _clipRightView = view;
310
        view.backgroundColor = [UIColor blackColor];
311
        view.alpha = 0.5;
312
        UIViewController *vc = [self getViewController];
313
        [vc.view addSubview:_clipRightView];
314
    }
315
    return _clipRightView;
316
}
317
318
-(UIView *)clipTopView{
319
    if (_clipTopView==nil) {
320
        UIView *view = [[UIView alloc] init];
321
        _clipTopView = view;
322
        view.backgroundColor = [UIColor blackColor];
323
        view.alpha = 0.5;
324
        UIViewController *vc = [self getViewController];
325
        [vc.view addSubview:_clipTopView];
326
    }
327
    return _clipTopView;
328
}
329
330
-(UIView *)clipBottomView{
331
    if (_clipBottomView==nil) {
332
        UIView *view = [[UIView alloc] init];
333
        _clipBottomView = view;
334
        view.backgroundColor = [UIColor blackColor];
335
        view.alpha = 0.5;
336
        UIViewController *vc = [self getViewController];
337
        [vc.view addSubview:_clipBottomView];
338
    }
339
    return _clipBottomView;
340
}
341
342
#pragma mark - other
343
-(void)captureScreen:(NSArray *)params{
344
    BOOL isCapture = false;
345
    if (params.count>0) {
346
        if (params[0]==[NSNull null]) {
347
            isCapture = false;
348
        }else{
349
            isCapture = [params[0] boolValue];
350
        }
351
    }
352
    if (isCapture) {//允许截屏
353
        
354
    }else{//禁止截屏
355
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenFullShot) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
356
    }
357
}
358
359
360
@end

+ 5 - 0
IpuLib/IpuLib.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist

@ -9,6 +9,11 @@
9 9
			<key>orderHint</key>
10 10
			<integer>21</integer>
11 11
		</dict>
12
		<key>IPULib.xcscheme_^#shared#^_</key>
13
		<dict>
14
			<key>orderHint</key>
15
			<integer>3</integer>
16
		</dict>
12 17
	</dict>
13 18
</dict>
14 19
</plist>