CGSize
struct CGSize
-
Mechanica
Returns the scale to fit
selfinto a differentsize.Declaration
Swift
public func scaleToFit(boundingSize size: CGSize) -> CGFloatParameters
sizeThe size to fit into.
Return Value
The scale to fit into the given size.
-
Mechanica
Returns a
CGSizeto fitselfinto thesizeby 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) -> CGSizeParameters
sizeThe size to fit into.
Return Value
Returns a
CGSizeto fitselfinto thesizeby 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
CGSizetoself.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
CGPointwith 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
selfwith 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)
CGSize Extension Reference