美文网首页程序员
iOS - 修改图片大小

iOS - 修改图片大小

作者: biubiuboom | 来源:发表于2020-05-10 11:33 被阅读0次
- (UIImage *)originImage:(UIImage *)image scaleToSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);  //size 为CGSize类型,即你所需要的图片尺寸
     
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
     
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
     
    UIGraphicsEndImageContext();
     
    return scaledImage;   //返回的就是已经改变的图片
}

相关文章

网友评论

    本文标题:iOS - 修改图片大小

    本文链接:https://www.haomeiwen.com/subject/dnadnhtx.html