CGSize

struct CGSize
  • Mechanica

    Returns the scale to fit self into a different size.

    Declaration

    Swift

    public func scaleToFit(boundingSize size: CGSize) -> CGFloat

    Parameters

    size

    The size to fit into.

    Return Value

    The scale to fit into the given size.

  • Mechanica

    Returns a CGSize to fit self into the size by maintaining the aspect ratio.

    Example:

    CGSize(width: 100, height: 50).aspectFit(boundingSize: CGSize(width: 70, height: 30)) -> CGSize(width: 60, height: 30)
    

    Declaration

    Swift

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

    Parameters

    size

    The size to fit into.

    Return Value

    Returns a CGSize to fit self into the size by maintaining the aspect ratio.

  • Mechanica

    Adds two CGSize.

    Example:

    CGSize(width: 10, height: 10) + CGSize(width: 20, height: 10) -> CGSize(width: 30, height: 20)
    

    Declaration

    Swift

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

    Adds a CGSize to self.

    Example:

    var size = CGSize(width: 10, height: 10)
    size += CGSize(width: 20, height: 10) -> point is equal to CGSize(width: 30, height: 20)
    

    Declaration

    Swift

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

    Subtracts two CGSize.

    Example:

    CGSize(width: 20, height: 10) - CGSize(width: 10, height: 5) -> CGSize(width: 10, height: 5)
    

    Declaration

    Swift

    public static func - (lhs: CGSize, rhs: CGSize) -> CGSize
  • Mechanica

    Subtracts a CGSize from self.

    Example:

    var size = CGSize(width: 20, height: 10)
    size -= CGSize(width: 10, height: 5) -> point is equal to CGSize(width: 10, height: 5)
    

    Declaration

    Swift

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

    Multiplies a CGPoint with a scalar.

    Example:

    CGSize(width: 20, height: 10) * 3 -> CGSize(width: 60, height: 30)
    

    Declaration

    Swift

    public static func * (size: CGSize, scalar: CGFloat) -> CGSize
  • Mechanica

    Multiply self with a scalar.

    Example:

    var size = CGSize(width: 20, height: 10)
    size *= 3 -> point is equal to CGSize(width: 60, height: 30)
    

    Declaration

    Swift

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