- ( UIImage *)imageWithImageSimple:( UIImage *)image scaledToSize:( CGSize )newSize{
// Create a graphics image context
// 创建一个bitmap的context
// 并把它设置成为当前正在使用的context
//Determine whether the screen is retina
if(\[\[UIScreen mainScreen\] scale\] == 3.0)\{
UIGraphicsBeginImageContextWithOptions(newSize, NO, 3.0);
\}elseif (\[\[UIScreen mainScreen\] scale\] == 2.0)\{
UIGraphicsBeginImageContextWithOptions(newSize, NO, 2.0);
\}else\{
UIGraphicsBeginImageContext(newSize);
\}
// UIGraphicsBeginImageContext (newSize);
// Tell the old image to draw in this new context, 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;
\}
还没有评论,来说两句吧...