I have UIImage and I want to scale it without setting it into UIImageView. How I can do that ?
As @rckoenes mentioned, UIImage is simply an image object, it does not handle display, which is precisely what UIImageView is for.
For pinch zooming an image, the easiest way is to add a UIImageView as a subview to a UIScrollView .
If what you wanted was to change the size of your UIImage, I answered this here: set size of an image programatically
Simply do this:
// Given a UIImage image and a CGSize newSize:
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Your scaled image is now in newImage
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.