Prevent iOS from taking screen capture of app before going into background

后端 未结 10 2684
Happy的楠姐
Happy的楠姐 2020-11-29 22:35

You all might know that iOS takes a screen shot of your application before throwing it into the background. This is usually for a better User experience like quick animation

10条回答
  •  臣服心动
    2020-11-29 23:06

    Improvement in Depak Kumar post : Make a property UIImage *snapShotOfSplash;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[UIApplication sharedApplication] ignoreSnapshotOnNextApplicationLaunch];
    snapShotOfSplash =[UIImage imageNamed:@"splash_logo"];
    }
    
    - (void)applicationDidEnterBackground:(UIApplication *)application {
    
    
        self.overlayView = [[UIImageView alloc]initWithFrame:[self.window frame]];
        self.overlayView.backgroundColor = [UIColor whiteColor];
        [self.overlayView setImage:snapShotOfSplash];
        [self.overlayView setContentMode:UIViewContentModeCenter];
        [self.window addSubview:self.overlayView];
        [self.window bringSubviewToFront:self.overlayView]; }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application {
    if(self.overlayView != nil) {
            [self.overlayView removeFromSuperview];
            self.overlayView = nil;
        }
    }
    

提交回复
热议问题