I have an image view, declared programmatically, and I am setting its image, also programmatically.
However, I find myself unable to set the image to both fit the aspect and align centre to the image view.
In other words, I want the image to:
How do I get that?
Just pasting the solution:
Just like @manohar said
imageView.contentMode = UIViewContentModeCenter; if (imageView.bounds.size.width > ((UIImage*)imagesArray[i]).size.width && imageView.bounds.size.height > ((UIImage*)imagesArray[i]).size.height) { imageView.contentMode = UIViewContentModeScaleAspectFit; }
solved my problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With