安卓系统
内
/android/app/src/main/java/com/{Project_Name}/MainActivity.java您可以添加以下几行。通过setFlag阻止捕获屏幕
FLAG_SECURE,使用以下代码作为示例:
import android.os.Bundle;import android.view.WindowManager;...@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);}稍后当您想删除安全标志时
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
iOS
中的重叠屏幕
AppDelegate.m,请看以下示例:
- (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]; }];}


