Skip to content

Instantly share code, notes, and snippets.

View JaydenIrwin's full-sized avatar
🏠
Working from home

Jayden Irwin JaydenIrwin

🏠
Working from home
View GitHub Profile
@jkosoy
jkosoy / CGSize+AspectFunctions.swift
Last active June 3, 2023 18:11
Aspect Fill and Aspect Fit calculations in Swift
// port of http://stackoverflow.com/a/17948778/3071224
import UIKit
import Foundation
extension CGSize {
static func aspectFit(aspectRatio : CGSize, var boundingSize: CGSize) -> CGSize {
let mW = boundingSize.width / aspectRatio.width;
let mH = boundingSize.height / aspectRatio.height;