CGSize

public extension CGSize
  • SwifterSwift: Returns the aspect ratio.

    Declaration

    Swift

    var aspectRatio: CGFloat { get }
  • SwifterSwift: Returns width or height, whichever is the bigger value.

    Declaration

    Swift

    var maxDimension: CGFloat { get }
  • SwifterSwift: Returns width or height, whichever is the smaller value.

    Declaration

    Swift

    var minDimension: CGFloat { get }

Methods

  • 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

    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

    func aspectFill(to boundingSize: CGSize) -> CGSize

    Parameters

    boundingSize

    bounding size to fill self to.

    Return Value

    self filled into given bounding size

Operators

  • SwifterSwift: Add two CGSize

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    let result = sizeA + sizeB
    // result = CGSize(width: 8, height: 14)
    

    Declaration

    Swift

    static func + (lhs: CGSize, rhs: CGSize) -> CGSize

    Parameters

    lhs

    CGSize to add to.

    rhs

    CGSize to add.

    Return Value

    The result comes from the addition of the two given CGSize struct.

  • SwifterSwift: Add a CGSize to self.

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    sizeA += sizeB
    // sizeA = CGPoint(width: 8, height: 14)
    

    Declaration

    Swift

    static func += (lhs: inout CGSize, rhs: CGSize)

    Parameters

    lhs

    self

    rhs

    CGSize to add.

  • SwifterSwift: Subtract two CGSize

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    let result = sizeA - sizeB
    // result = CGSize(width: 2, height: 6)
    

    Declaration

    Swift

    static func - (lhs: CGSize, rhs: CGSize) -> CGSize

    Parameters

    lhs

    CGSize to subtract from.

    rhs

    CGSize to subtract.

    Return Value

    The result comes from the subtract of the two given CGSize struct.

  • SwifterSwift: Subtract a CGSize from self.

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    sizeA -= sizeB
    // sizeA = CGPoint(width: 2, height: 6)
    

    Declaration

    Swift

    static func -= (lhs: inout CGSize, rhs: CGSize)

    Parameters

    lhs

    self

    rhs

    CGSize to subtract.

  • SwifterSwift: Multiply two CGSize

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    let result = sizeA * sizeB
    // result = CGSize(width: 15, height: 40)
    

    Declaration

    Swift

    static func * (lhs: CGSize, rhs: CGSize) -> CGSize

    Parameters

    lhs

    CGSize to multiply.

    rhs

    CGSize to multiply with.

    Return Value

    The result comes from the multiplication of the two given CGSize structs.

  • SwifterSwift: Multiply a CGSize with a scalar.

    let sizeA = CGSize(width: 5, height: 10)
    let result = sizeA * 5
    // result = CGSize(width: 25, height: 50)
    

    Declaration

    Swift

    static func * (lhs: CGSize, scalar: CGFloat) -> CGSize

    Parameters

    lhs

    CGSize to multiply.

    scalar

    scalar value.

    Return Value

    The result comes from the multiplication of the given CGSize and scalar.

  • SwifterSwift: Multiply a CGSize with a scalar.

    let sizeA = CGSize(width: 5, height: 10)
    let result = 5 * sizeA
    // result = CGSize(width: 25, height: 50)
    

    Declaration

    Swift

    static func * (scalar: CGFloat, rhs: CGSize) -> CGSize

    Parameters

    scalar

    scalar value.

    rhs

    CGSize to multiply.

    Return Value

    The result comes from the multiplication of the given scalar and CGSize.

  • SwifterSwift: Multiply self with a CGSize.

    let sizeA = CGSize(width: 5, height: 10)
    let sizeB = CGSize(width: 3, height: 4)
    sizeA *= sizeB
    // result = CGSize(width: 15, height: 40)
    

    Declaration

    Swift

    static func *= (lhs: inout CGSize, rhs: CGSize)

    Parameters

    lhs

    self.

    rhs

    CGSize to multiply.

  • SwifterSwift: Multiply self with a scalar.

    let sizeA = CGSize(width: 5, height: 10)
    sizeA *= 3
    // result = CGSize(width: 15, height: 30)
    

    Declaration

    Swift

    static func *= (lhs: inout CGSize, scalar: CGFloat)

    Parameters

    lhs

    self.

    scalar

    scalar value.