調(diào)整UIImage大小的最簡(jiǎn)單方法?在我的iPhone應(yīng)用程序中,我用相機(jī)拍了一張照片,然后我想把它調(diào)整到290*390像素。我使用這個(gè)方法來調(diào)整圖像的大?。篣IImage *newImage = [image _imageScaledToSize:CGSizeMake(290, 390)
interpolationQuality:1];它工作得很完美,但是它是一個(gè)沒有文檔的功能,所以我不能再在iPhoneOS 4上使用它了。所以.。調(diào)整UIImage大小的最簡(jiǎn)單方法是什么?
3 回答

侃侃無極
TA貢獻(xiàn)2051條經(jīng)驗(yàn) 獲得超10個(gè)贊
UIImageView
contentMode
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { //UIGraphicsBeginImageContext(newSize); // In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution). // Pass 1.0 to force exact pixel size. UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage;}
#import "MYUtil.h"…UIImage *myIcon = [MYUtil imageWithImage:myUIImageInstance scaledToSize:CGSizeMake(20, 20)];
- 3 回答
- 0 關(guān)注
- 1317 瀏覽
添加回答
舉報(bào)
0/150
提交
取消