Fit UIImageView to image content
Is it possible to fit perfectly an UIImageView to its content, so that:
the origins of the image and the UIImageView object coincide;
the frame of the image and the UIImageView object coincide?
I tried using the following code:
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.imageView setBounds:CGRectMake(self.imageView.bounds.origin.x,
self.imageView.bounds.origin.y,
self.imageView.bounds.origin.x +
self.imageView.image.size.width,
self.imageView.bounds.origin.y +
self.imageView.image.size.height)];
However, in this way the UIImageView object starts at (0,0), while the
image is centered on the screen.
Thanks in advance.
No comments:
Post a Comment