0x00 直接看图

看图演示,可防止​​截屏​​​和​​录屏​​​ 可以开启或者关闭,是否允许​​截屏​​和​​录屏​

iOS 防止截屏、录屏技术_ico


0x01 代码

    JHNonRecordableView *view1 = [[JHNonRecordableView alloc] init];
view1.tag = 100;
[self.view addSubview:view1];
view1.frame = self.view.bounds;

// 截屏,或者录屏时,下面 2 个控件将不可见
[view1.contentView addSubview:({
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(20, 200, 200, 40);
label.text = @"一个标签,可以点击";
label.backgroundColor = [UIColor lightGrayColor];
label.textColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:14];
label.textAlignment = NSTextAlignmentLeft;
label.userInteractionEnabled = YES;
[label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap)]];

UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(180, 0, 20, 20);
imageView.backgroundColor = [UIColor redColor];
[label addSubview:imageView];

label;
})];

[view1.contentView addSubview:({
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(20, 250, 100, 60);
button.backgroundColor = [UIColor lightGrayColor];
button.titleLabel.font = [UIFont systemFontOfSize:16];
button.showsTouchWhenHighlighted = YES;
[button setTitle:@"截屏不展示" forState:0];
[button setTitleColor:[UIColor blackColor] forState:0];
[button addTarget:self action:@selector(buttonEvent:) forControlEvents:1<<6];
button;
})];

​有偿提供​


0x02 我的小作品

欢迎体验我的作品之一:​​小笔记-XNote​​​ 笔记一步到位!
​App Store​​ 搜索即可~