CGSize

struct CGSize
  • SwifterSwift: Aspect fit CGSize.

    let rect = CGSize(width: 120, height: 80)
    let parentRect  = CGSize(width: 100, height: 50)
    let newRect = rect.aspectFit(to: parentRect)
    //newRect.width = 75 , newRect = 50
    

    Declaration

    Swift

    public func aspectFit(to boundingSize: CGSize) -> CGSize

    Parameters

    boundingSize

    bounding size to fit self to.

    Return Value

    self fitted into given bounding size

  • SwifterSwift: Aspect fill CGSize.

    let rect = CGSize(width: 20, height: 120)
    let parentRect  = CGSize(width: 100, height: 60)
    let newRect = rect.aspectFit(to: parentRect)
    //newRect.width = 100 , newRect = 60
    

    Declaration

    Swift

    public func aspectFill(to boundingSize: CGSize) -> CGSize

    Parameters

    boundingSize

    bounding size to fill self to.

    Return Value

    self filled into given bounding size