A UIColor Extension written in Swift for convenience purposes.
This extension:
- Saves your time from converting Hex codes to RGB colors manually
- Gives you access to more standard or sophisticated colors with much convenience
- Provides you with awesome sample gradient background colors AND easy way to customize your own!
1. Drop this extension file into your Swift project 2. Instantiate UIColor 3. Implement the delightful methods!
Example1
let superAwesomeColor = UIColor()
self.view.backgroundColor = superAwesomeColor.convertHexStringToColor("Insert the hex color code string here")
Example2
let amazingColor = UIColor()
self.view.backgroundColor = amazingColor.convertHexToRGB(Insert your UInt32 Color Hex Code here)
Example3
let delightfulColor = UIColor()
self.view.backgroundColor = delightfulColor.Insert the delightful colors name()
The gradient feature in this extension changes the background of the specified view to your choice of gradient. Example 4 and 5 are sample usage of the gradient feature.
Example4
let exquisiteGradient = UIColor()
let backgroundView: UIView = exquisiteGradient.Insert name of gradient(Insert targeted view ex. self.view)
Example5
let beautifulGradient = UIColor()
self.view = beautifulGradient.theGradientBackground(self.view, hexColor1: Insert hex color string ex. "eef2f3", hexColor2: Insert hex color string ex. "70e1f5")
You can create your own gradient colors as seen in Example 5. However, this extension has some sweet gradient background available:
Name of Gradient | Gradient |
---|---|
FieryOrange | |
BlueOcean | |
DeepBlue | |
MaceWindu | |
MojitoBlast | |
LovelyPink | |
Haze | |
Beach | |
Metalic | |
OrangeMango |
If you liked it, stars are appreciated. If you want, feel free to fork or pull. =]