1

I'm trying to remove the top and bottom space of an image that is set to "aspect fit". I would think there is an easier way to just make an image adjust to the screen width and then adjust the height to whatever is scaled correctly like I do with anything on the web, but I guess there is not in xcode.

So now i'm trying to adjust the frame size after the aspect fit. I've been able to find the frame size and image size after going here: How to get the size of a scaled UIImage in UIImageView?

I can apply the new frame settings like this

    //func from extension
    let newSize = mainImage.frameForImageInImageViewAspectFit()

    let newHeight = CGRectGetHeight(newSize)
    let newWidth = CGRectGetWidth(newSize)

    mainImage.frame.size.height = newHeight
    mainImage.frame.size.width = newWidth

But i'm still at a loss where to apply those and all the labels are still aligned to the original imageview after I resize it. Is there an easier way to just get the layout in the bottom right?

Thanks for any help.

enter image description here

Community
  • 1
  • 1
Keith
  • 1,969
  • 4
  • 17
  • 27
  • is this placed inside the `UITableView`? – jo3birdtalk Sep 07 '16 at 04:17
  • Thanks for the reply. Not it's in a stack view in a regular view controller. – Keith Sep 07 '16 at 04:20
  • did you add constraints on the imageview, or add constraints on the stackview? – jo3birdtalk Sep 07 '16 at 04:24
  • also please check inside your stackview if you did align top your items – jo3birdtalk Sep 07 '16 at 04:29
  • Thanks for the replies. On the image and label I have trailing and leading to superview set. 0 for the image and 10 for the label text. The label I have top space to main image with 14. The main image I have top to layout with 0 and bottom space to text 14. Also, I'm not quite sure where I apply the image view sizing. It's in view did appear at the moment but it only works sometimes. – Keith Sep 07 '16 at 05:25

0 Answers0