-1

Given a UIImageView using AspectFit how can I calculate the height of any whitespace above and below the UIImage?

Schuey999
  • 4,706
  • 7
  • 21
  • 36

1 Answers1

-1

You can do it easily when calculate the scale of the image:

let horizontalRatio = image.size.width / uiimageView.frame.size.width
let verticalSpacing = uiimageView.frame.size.height * horizontalRatio

And probably it is vertically in the middle

let whitespaceAbove = verticalSpacing / 2
let whitespaceBelow = verticalSpacing / 2