Reputation: 1203
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?
Upvotes: 7
Views: 2379
Reputation: 4375
YourImageView.contentMode=UIViewContentModeScaleAspectFit;
Maybe the problem is coming because of your contentMode ,so please your imageView content mode.
If you are developing application for a single phone then use aspect fit for that[constraints]
Upvotes: 1
Reputation: 1559
This line should resolve your problem :
yourImageView.clipsToBounds = true
You can do it in Storyboard by checking the "Clip Subviews" of your UIImageView element.
Upvotes: 3
Reputation: 509
If you are getting image from server then you should resize the image according to your imageView size ...its a best practice.
Upvotes: 1