0
votes

I am developing an app where I want the UIImageview like instagram feed. I set the leading and trailing space to mainview as zero so width is now 100% of screen. Now how do i set the height so that it varies depending on image's scale. I tried setting content mode to Aspect Fit, but its not working and blank spaces are coming in the left and right side for a portrait mode image

Sample Image i selected Selected Image

How it came after selecting in UIIMageView

Image in UIImageView

1
please show the code that have been written also share how the UI will be looking like.Sateesh Yemireddi
set Aspect Fill instead Aspect Fit this will adjust image width without changing it's Aspect ratio.Abdul Rehman
your UIImageView is part of TableViewCell?ibnetariq
@Sateesh added screenshots to postAnoop Krishnan
@ibnetariq no its not part of tableviewcellAnoop Krishnan

1 Answers

0
votes

To solve this issue you need to get Image dimension in Height and Width from server side for each image. Then Accroding to Image Width, Image Height, Screen width you have to calculate new Image Height and Set it to ImageView Height by taking Image View Height Constraint.

let calculatedImageHeight = (screenWidth * imageHeight)/imageWidth