欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

iOS 截屏代码,ios截屏代码

来源: 开发者 投稿于  被查看 14215 次 评论:240

iOS 截屏代码,ios截屏代码


-(UIImage*)getScreenPhoto{

    CGFloat scale = [UIScreen mainScreen].scale;

    NSMutableArray *images = [NSMutableArray array];

    

    CGSize contentSize = self.view.size;

    

    CGSize imageSize = CGSizeMake(contentSize.width * scale, contentSize.height * scale);

    

    UIGraphicsBeginImageContextWithOptions(self.view.size, NO, 0.0);

    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    [images addObject:image];

    

    UIGraphicsBeginImageContext(imageSize);

    

    [images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) {

        [image drawInRect:CGRectMake(0, scale * EJScreenH * idx, EJScreenW * scale, EJScreenH * scale)];

    }];

    UIImage *fullImage = UIGraphicsGetImageFromCurrentImageContext();

    

    UIGraphicsEndImageContext();

  return fullImage;

    

}

用户评论