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

后端 未结 10 2665
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:07

    Need to write the code in Application life cycle methods, here we are putting an imageView while the app animate to background :

    -(void)applicationWillResignActive:(UIApplication *)application
    {
        imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];
        [imageView setImage:[UIImage imageNamed:@"Splash_Screen.png"]];
        [self.window addSubview:imageView];
    }
    

    Here is the code to remove the imageView:

    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
        if(imageView != nil) {
            [imageView removeFromSuperview];
            imageView = nil;
        }
    }
    

    It is working and properly tested.

提交回复
热议问题