iOS 截取当前屏幕的方法

来源:互联网 发布:网站名与域名的区别 编辑:程序博客网 时间:2024/05/08 14:41
//截取当前屏幕的方法- (UIImage *)getSnapshotImage {    UIGraphicsBeginImageContextWithOptions(CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds)), NO, 0.0);    [[(AppDelegate *)[UIApplication sharedApplication].delegate window] drawViewHierarchyInRect:CGRectMake(0, 0, CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds)) afterScreenUpdates:NO];    UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return snapshot;}



0 0
原创粉丝点击