I have a UIImageView and used autolayout to add height and width constraints (and other ones as well). There are no conflicting constraints or warnings. I am querying an image from a database and setting the imageview's image to that image. However, the image is showing up with a much larger height than I have specified via constraints. How do I fix this?
This line should resolve your problem :
yourImageView.clipsToBounds = true
You can do it in Storyboard by checking the "Clip Subviews" of your UIImageView element.
1
YourImageView.contentMode=UIViewContentModeScaleAspectFit;
May be the problem is coming because of your contentMode ,so please your imageView content mode.
2.if you are developing application for a single phone then use aspect fit for that[constraints]
If you are getting image from server then you should resize the image according to your imageView size ...its a best practice.
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