Image resize and fill screen in iphone?
I am getting images asynchronously and show them on small frame (135,126) and on big fra开发者_如何学JAVAme (280,325) and image can be any size but frames are fixed and must have to fill frames, now my question is how resize image to fill these sizes of frame but quality should not reduce and also orientation of images like UIViewContentModeScaleAspectFill property do????
UIImage *image = [actualImage you want to resize];
UIImage *tempImage = nil;
CGSize targetSize = CGSizeMake(196,110);
UIGraphicsBeginImageContext(targetSize);
CGRect thumbnailRect = CGRectMake(0, 0, 0, 0);
thumbnailRect.origin = CGPointMake(0.0,0.0);
thumbnailRect.size.width = targetSize.width;
thumbnailRect.size.height = targetSize.height;
[image drawInRect:thumbnailRect];
tempImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
You can use this tempImage , it will be resized Image
Hope, it helps !
精彩评论