1
votes
CGRect imageLocation = CGRectMake(startingXCoordinate, startingYCoordinate + detailedTitleLabel.frame.size.height + marginY, 280, 300);
self.detailedImageView.frame = imageLocation;

This is the code I've got so far. You can see the width is 280 and the height is 300 for now... In the interface builder, I also set this image view as 'Aspect Fit' to keep the ratio.

The problem here is... for some bigger or smaller images, they're located in the centre of the UIImageView and it naturally creates some extra top & bottom margins. How can I make a perfectly fitting UIImageView not ruining the ratio with 280 width?

Thank you in advance

1
Can your images be wider than 280px or is it just the height that varies from one image to the other ?Ignacio Inglese
Every pic has different size. However, I'd say the minimum width is 280px.Raccoon
btw, I just hard-coded the solution.. for those who may have the same question in the future...Raccoon
CGRect imageLocation = CGRectMake(startingXCoordinate, startingYCoordinate + detailedTitleLabel.frame.size.height + marginY, 280, (280 * expectedImageSize.height)/expectedImageSize.width);Raccoon

1 Answers

0
votes

Did you try aspect fill instead of aspect fit? That should have solved your issue, I think.