标签:scale logs blog ima log image new oat actual
+ (CGRect )scaleImage:(UIImage *)image toSize:(CGRect)newSize { float actualHeight = image.size.height; float actualWidth = image.size.width; float imgRatio = actualWidth/actualHeight; float maxRatio = newSize.size.width/newSize.size.height; if(imgRatio!=maxRatio){ if(imgRatio < maxRatio){ imgRatio = newSize.size.height/ actualHeight; actualWidth = imgRatio * actualWidth; actualHeight = newSize.size.height; } else{ imgRatio = newSize.size.width / actualWidth; actualHeight = imgRatio * actualHeight; actualWidth = newSize.size.width; } } CGRect rect = CGRectMake(0.0, 0.0, actualWidth, actualHeight); return rect; } 调用时候 rect的宽和高 就是所需要得新的图片大小
iOS -- 网络/本地 图片 按自定义比例缩放 不失真 方法
标签:scale logs blog ima log image new oat actual
原文地址:http://www.cnblogs.com/mafeng/p/7614746.html