我尝试使用下面的代码调整图像大小以适合框架,但图像有点失真。
+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {
UIGraphicsBeginImageContext( newSize );
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
UIImage* image =[UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
deal.Image=[tfbImageHelper imageWithImage:image scaledToSize:newSize];