1、監聽系統截屏通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserDidTakeScreenshotNotification:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
2、監聽到截屏后獲取屏幕截屏圖片
UIWindow *window = [[[UIApplication sharedApplication] delegate] window]; // 1.開啟上下文 UIGraphicsBeginImageContextWithOptions(window.bounds.size, window.opaque, 0); // 2.渲染 [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO]; // 3.獲取圖片 UIImage *snapshotImage=UIGraphicsGetImageFromCurrentImageContext(); // 4.結束上下文 UIGraphicsEndImageContext();
3、對圖片進行存儲本地或者服務器進行分享操作
