1

当应用程序进入后台状态时,iOS 会自动截屏,并在进入前台时显示。可以从应用程序外部访问屏幕截图。

如果屏幕中有敏感数据,这可能是一个安全问题。

我就是这样处理这个问题的,如果有更好的方法,请提出建议。

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Add overlay image to prevent automatic screenshot while entering background

    // prepare image to display
self.splashImageView = [[UIImageView alloc] initWithImage:image];

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    CGFloat angle = [self angleForOrientation:orientation];
    CGAffineTransform transform = CGAffineTransformMakeRotation(angle);    
    self.splashImageView.transform = transform;
    self.splashImageView.frame = self.window.frame;
    [self.window addSubview:self.splashImageView];
}



- (void)applicationWillEnterForeground:(UIApplication *)application
{
    if ([_splashImageView superview])
    {
        [_splashImageView removeFromSuperview];
        self.splashImageView = nil;
    }
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
4

0 回答 0