Int
public extension Int
-
Scale a value proportionally to the current screen width. Useful for making designed sizes look proportionally similar on all devices.
For instance, let’s say a certain button was meant to take up 30px of an iPhone 6s screen, but you’d like the width to scale proportionally to an iPhone SE:
>>> 30.scaledToDeviceWidth(baseWidth: 375) 25.6Date
February 17, 2016Declaration
Swift
func scaledToDeviceWidth(_ baseWidth: CGFloat) -> CGFloatParameters
baseWidthThe base width for the provided value.
Return Value
A
CGFloatthat represents the proportionally sized value. -
Convert an Int value representing RGBA color components into red, green, blue, and alpha CGFloat representations.
This is useful for converting something like a HEX representation of a color to RGBA. For instance:
var r: CGFloat! var g: CGFloat! var b: CGFloat! var a: CGFloat! 0xFF000000.toRGBA(&r, &g, &b, &a) // r = 1, g = 0, b = 0, a = 0Date
May 24, 2017Declaration
Swift
func toRGBA(_ r: inout CGFloat!, _ g: inout CGFloat!, _ b: inout CGFloat!, _ a: inout CGFloat!)Parameters
rThe variable to write the red color value to.
gThe variable to write the green color value to.
bThe variable to write the blue color value to.
aThe variable to write the alpha value to.
View on GitHub
Int Extension Reference