CCFoldCell icon indicating copy to clipboard operation
CCFoldCell copied to clipboard

截屏模糊变清晰处理

Open luoei opened this issue 8 years ago • 0 comments

方法一:

- (UIImage *)takeSnapshotWithFrame:(CGRect)frame
{
    
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0);
    [img drawInRect:CGRectMake(0, -frame.origin.y, img.size.width, img.size.height)];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return  image;
}

方法二:

- (UIImage *)takeSnapshotWithFrame:(CGRect)frame
{
    
    UIGraphicsBeginImageContextWithOptions(frame.size, NO, [UIScreen mainScreen].scale);
    
    [self drawViewHierarchyInRect:CGRectMake(0, -frame.origin.y, self.bounds.size.width, self.bounds.size.height) afterScreenUpdates:YES];
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();

    return  image;
}

方法二是贴出来讨论的,在效果上面欠缺。 @bref-Chan

luoei avatar Apr 24 '17 02:04 luoei