简体   繁体   English

如何在 react-native 中防止 iOS 屏幕截图

[英]How to prevent iOS screenshot in react-native

In my application I want to disable screen shots function for IOS in React-native.在我的应用程序中,我想在 React-native 中禁用 IOS 的屏幕截图功能。

Please suggest me any working package or any native code which can disable screen shots in IOS.请建议我任何可以在 IOS 中禁用屏幕截图的工作包或任何本机代码。

this is one of the solutions by the library react native prevent screenshot:, check out the link rn-screenshot这是库反应本机防止屏幕截图的解决方案之一:,查看链接rn-screenshot

Overlay screen by added 2 two into appDelegate.m通过在 appDelegate.m 中添加 2 个 2 来覆盖屏幕

- (void)applicationWillResignActive:(UIApplication *)application {

// fill screen with our own colour
UIView *colourView = [[UIView alloc]initWithFrame:self.window.frame];
colourView.backgroundColor = [UIColor whiteColor];
colourView.tag = 1234;
colourView.alpha = 0;
[self.window addSubview:colourView];
[self.window bringSubviewToFront:colourView];

// fade in the view
[UIView animateWithDuration:0.5 animations:^{
  colourView.alpha = 1;
}];
}

- (void)applicationDidBecomeActive:(UIApplication \*)application {
// grab a reference to our coloured view
UIView \*colourView = [self.window viewWithTag:1234];
// fade away colour view from main view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 0;
} completion:^(BOOL finished) {
// remove when finished fading
[colourView removeFromSuperview];
}];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM