Latest 4.2.0
Homepage https://github.com/yeahdongcn/UIColor-Hex-Swift
License MIT
Platforms ios 8.0, tvos 9.0, watchos 2.1, requires ARC
Frameworks UIKit
Authors

UIColor_Hex_Swift

UIColor+Hex, now Swift.
Build Status codecov.io UIColor_Hex_Swift Carthage compatible UIColor_Hex_Swift

Convenience method for creating autoreleased color using RGBA hex string.

    // Solid color
    let strokeColor = UIColor("#FFCC00").CGColor 

    // Color with alpha
    let fillColor = UIColor("#FFCC00DD").CGColor 

    // Supports shorthand 3 character representation
    let backgroundColor = UIColor("#FFF") 

    // Supports shorthand 4 character representation (with alpha)
    let menuTextColor = UIColor("#013E") 

    // "#FF0000FF"
    let hexString = UIColor.redColor().hexString()

    // Convert shorthand 4 character representation (with alpha) from argb to rgba
    if let rgba = "#AFFF".argb2rgba() {            
        let androidBackgroundColor = UIColor(rgba)
    }

    // Convert 8 character representation (with alpha) from argb to rgba
    if let rgba = "#AAFFFFFF".argb2rgba() {        
        let androidFrontColor = UIColor(rgba)
    }

Installation

CocoaPods

Simply add the following lines to your Podfile:

# required by CocoaPods 0.36.0.rc.1 for Swift Pods
use_frameworks! 

pod 'UIColor_Hex_Swift', '~> 4.2.0'

Then import it where you use it:

import UIColor_Hex_Swift

(CocoaPods v0.36 or later required. See this blog post for details.)

Carthage

Simply add the following line to your Cartfile:

github "yeahdongcn/UIColor-Hex-Swift" >= 4.2.0

Then add the HexColor.framework to your frameworks list in the Xcode project.

Then import it where you use it:

import HEXColor

See more in RSBarcodes_Swift and objc version

Latest podspec

{
    "name": "UIColor_Hex_Swift",
    "version": "4.2.0",
    "summary": "Convenience method for creating autoreleased color using RGBA hex string.",
    "homepage": "https://github.com/yeahdongcn/UIColor-Hex-Swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "R0CKSTAR": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0",
        "watchos": "2.1"
    },
    "source": {
        "git": "https://github.com/yeahdongcn/UIColor-Hex-Swift.git",
        "tag": "4.2.0"
    },
    "source_files": "HEXColor/*.{h,swift}",
    "frameworks": [
        "UIKit"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This