Home

Awesome

UIColor+HexUtils Badge w/ Version Platform Carthage compatible Build Status license MIT

UIColor-HexUtils is a category for Hexadecimal Colors Support for UIColor. Support for prefixed # (#FFFFFF) or without (FFFFFF) Hexadecimal Colors.

RELEASE 2.0

Upgrade to Swift 5.

RELEASE 1.1

Updated Demo Project for CocoaPods and Fixes.

RELEASE 1.0

The base UIColor+Hex category with the required hex transformation functions.

Examples

Swift 5.0

// with hash
let colorHash = UIColor(hex: "#FFFFFF")

// without hash
let colorNoHash = UIColor(hex: "FFFFFF")

// short Hex
let colorShort = UIColor(hex: "FFF")

Demo Project

Check on Example Directory for the UIColor-HexUtilsExample project with Unit Tests.

Installation

CocoaPods

platform  :ios

target 'YourTarget' do
  pod 'UIColor-HexUtils', :git => "https://github.com/devcarlos/UIColor-HexUtils.git"
end

Carthage

  1. Get Carthage by running brew install carthage or choose another installation method

  2. Create a [Cartfile][] in the same directory where your .xcodeproj or .xcworkspace is

  3. List the desired dependencies in the [Cartfile][], for example:

    github "UIColor-HexUtils"
    
  4. Run carthage update

  5. A Cartfile.resolved file and a Carthage directory will appear in the same directory where your .xcodeproj or .xcworkspace is

  6. Drag the built .framework binaries from Carthage/Build/<platform> into your application’s Xcode project.

  7. If you are using Carthage for an application, follow the remaining steps, otherwise stop here.

  8. On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:

    /usr/local/bin/carthage copy-frameworks
    

Requirements

UIColor+HexUtils requires iOS 10.0 and above.

Credits

UIColors+HexUtils was created by Carlos Alcala because I was using in a lot of projects and wanted to contribute (and avoid the pain to always search for this functionality).

Creator

Carlos Alcala @carlosalcala

License

UIColors-HexUtils is available under the MIT license. See the LICENSE file for more info.