mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-05-25 18:32:22 +08:00
16 lines
455 B
Swift
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))
|
|
}
|