CGFloat
extension CGFloat
-
Generate a random CGFloat bounded by a closed interval range.
Declaration
Swift
public static func random(_ range: ClosedRange<CGFloat>) -> CGFloat -
Generate a random CGFloat bounded by a range from min to max.
Declaration
Swift
public static func random(min: CGFloat, max: CGFloat) -> CGFloat -
Round self to a specified number of decimal places.
Examples:
let val: CGFloat = 12.345678 val.rounded(places: 2) // 12.35 val.rounded(places: 3) // 12.346Declaration
Swift
public func rounded(places: UInt) -> CGFloatParameters
placesThe number of decimal places by which to round self.
Return Value
A CGFloat value, rounded to the specified number of decimal places.
View on GitHub
Install in Dash
CGFloat Extension Reference