An iOS helper class for creating a UIImage
from a UIColor
.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate UIImageColorSwift into your Xcode project using CocoaPods, specify it in your Podfile
:
platform :ios, '8.3'
use_frameworks!
pod 'UIImageColorSwift', '~> 1.0.1'
Then, run the following command:
$ pod install
- Add the
UIImage+Color.swift
file from theSources
folder to your Xcode project.
For creating a UIImage
from a UIColor
let image = UIImage.imageFromColor(UIColor.blue)
// Applying the image to the background of a UIButton
button.setBackgroundImage(image, forState: .normal)
To specify the size of the image:
let image = UIImage.imageFromColor(UIColor.blue, width: 1.0, height: 2.0)
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See the Code of Conduct file.
UIImageColorSwift is released under the MIT License. See License.