UIColor-Hex-Swift

Convenience methods for creating color using RGBA hex string.

  • 所有者: yeahdongcn/UIColor-Hex-Swift
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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

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)
    }

Release Notes

  • Upgrade to Swift 5.
  • macOS gets supported.

Installation

Swift Package Manager

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter https://github.com/yeahdongcn/UIColor-Hex-Swift to the text field.

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', '~> 5.1.1'

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" >= 5.1.1

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

主要指標

概覽
名稱與所有者yeahdongcn/UIColor-Hex-Swift
主編程語言Swift
編程語言Swift (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2014-06-13 05:34:37
推送於2023-11-22 08:30:10
最后一次提交2023-11-22 16:30:10
發布數27
最新版本名稱5.1.9 (發布於 2022-08-11 09:45:30)
第一版名稱1.0 (發布於 2015-07-04 05:57:46)
用户参与
星數1.2k
關注者數19
派生數143
提交數227
已啟用問題?
問題數43
打開的問題數5
拉請求數29
打開的拉請求數0
關閉的拉請求數15
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?