zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

iOS:压缩图片详解手机开发

ios手机开发 详解 图片 压缩
2023-06-13 09:20:12 时间
 UIImage*img= [self imageWithImageSimple:image scaledToSize:CGSizeMake(210.0, 210.0)];//压缩图片 

 - (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize 

 // Create a graphics image context 

 UIGraphicsBeginImageContext(newSize); // Tell the old image to draw in this newcontext, with the desired 

 // new size 

 [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; 

 // Get the new image from the context 

 UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 

 // End the context 

 UIGraphicsEndImageContext(); 

 // Return the new image. 

 return newImage; 

 } 

5191.html

app程序应用开发手机开发无线开发移动端开发