在计算图像的比例时,您可以轻松地做到这一点:
let horizontalRatio = image.size.width / uiimageView.frame.size.width
let verticalSpacing = uiimageView.frame.size.height * horizontalRatio
可能它垂直在中间
let whitespaceAbove = verticalSpacing / 2
let whitespaceBelow = verticalSpacing / 2