Files
GitHawk/Classes/Views/BoundedImageSize.swift
Ryan Nystrom 4adf511ea4 Comment cell images don't scale to fit (#903)
* images scale to top

* layout image view based on image size
2017-11-09 10:37:12 -05:00

16 lines
455 B
Swift

//
// BoundedImageSize.swift
// Freetime
//
// Created by Ryan Nystrom on 11/9/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
func BoundedImageSize(originalSize: CGSize, containerWidth: CGFloat) -> CGSize {
guard originalSize.width > containerWidth else { return originalSize }
let ratio = originalSize.width / originalSize.height
return CGSize(width: containerWidth, height: ceil(containerWidth / ratio))
}