Color2UiColor
Example
To run the example project, clone the repo, and go into it with cd color2UiColor
and run pod install
inside.
Requirements
- iOS8
Installation
Color2UiColor is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Color2UiColor'
Usage
At the top of your file import Color2UiColor
import Color2UiColor
Initialize an object of Color2UiColor
let c2uic = Color2UiColor()
Color2UiColor is packed with two methods for you:
hexToUIColor(hex: String)
rgbToUIColor(r: Int, g: Int, b: Int)
You can use they like so
button.tintColor = c2uic.hexToUIColor(hex: "#b10034")
button.tintColor = c2uic.rgbToUIColor(r: 123, g: 456, b: 789)
If you have to set the opacity just add an alpha value at the end of parameter list
hexToUIColor(hex: String, alpha: CGFloat)
rgbToUIColor(r: Int, g: Int, b: Int, alpha: CGFloat)
Example for method call with alpha value
button.tintColor = c2uic.hexToUIColor(hex: "#b10034", alpha: 0.4)
button.tintColor = c2uic.rgbToUIColor(r: 123, g: 456, b: 789, alpha: 0.75)
Author
Name: Maurice Gerhardt
Twitter: @mrcgrhrdt
License
Color2UiColor is available under the MIT license. See the LICENSE file for more info.