压缩图片,直接使用大图,在小控件上会有毛边

使用UIImage+YYAdd.h的:

- (UIImage *)imageByResizeToSize:(CGSize)size {
    if (size.width <= 0 || size.height <= 0) return nil;
    UIGraphicsBeginImageContextWithOptions(size, NO, self.scale);
    [self drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

 

posted on 2018-05-10 18:39  土匪7  阅读(159)  评论(0编辑  收藏  举报