類似於支付寶項目,在雙擊home鍵之後應用程序進入後台程序,然後這時候將應用程序頁面隱藏,然後顯示一樣默認圖片
// After didFinish addObserver accept Notification [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(userDidTakeScreenshot) name:UIApplicationDidEnterBackgroundNotification object:nil];
- (void)userDidTakeScreenshot { self.lockView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; UIImage *image = [UIImage imageNamed:@"Personal_logo.jpg"]; self.lockView.image = image; [self.window addSubview:self.lockView]; }
- (void)applicationDidBecomeActive:(UIApplication *)application { // 進入前台移除視圖 if (self.lockView) { [self.lockView removeFromSuperview]; self.lockView = nil; } // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. }