现在的位置: 首页 > 综合 > 正文

IOS 截图代码

2018年05月26日 ⁄ 综合 ⁄ 共 360字 ⁄ 字号 评论关闭
全屏截图:
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); //viewImage为当前屏幕的截图
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);//保存到相册

抱歉!评论已关闭.