Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yeahdongcn/UIColor-Hex-Swift
Convenience methods for creating color using RGBA hex string.
https://github.com/yeahdongcn/UIColor-Hex-Swift
Last synced: 3 months ago
JSON representation
Convenience methods for creating color using RGBA hex string.
- Host: GitHub
- URL: https://github.com/yeahdongcn/UIColor-Hex-Swift
- Owner: yeahdongcn
- License: mit
- Created: 2014-06-13T05:34:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T08:30:10.000Z (12 months ago)
- Last Synced: 2024-05-22T03:01:41.679Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 183 KB
- Stars: 1,237
- Watchers: 19
- Forks: 144
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - UIColor-Hex-Swift - Convenience method for creating autoreleased color using RGBA hex string. (Color / Linter)
- awesome-swift - UIColor-Hex-Swift - Hex to UIColor converter. (Libs / Colors)
- awesome-swift - UIColor-Hex-Swift - Hex to UIColor converter. (Libs / Colors)
- awesome-ios - UIColor-Hex-Swift
- fucking-awesome-swift - UIColor-Hex-Swift - Hex to UIColor converter. (Libs / Colors)
- awesome-ios-star - UIColor-Hex-Swift - Convenience method for creating autoreleased color using RGBA hex string. (Color / Linter)
- awesome-swift-cn - UIColor-Hex-Swift - Hex to UIColor converter. (Libs / Colors)
- awesome-ios-cn - 官网
- fucking-awesome-ios - UIColor-Hex-Swift - Convenience method for creating autoreleased color using RGBA hex string. (Color / Linter)
- fucking-awesome-ios - UIColor-Hex-Swift - Convenience method for creating autoreleased color using RGBA hex string. (Color / Linter)
- awesome-swift - UIColor-Hex-Swift - Convenience methods for creating color using RGBA hex string. ` 📝 9 months ago ` (Colors [🔝](#readme))
README
UIColor+Hex, now Swift.
[![Build Status](https://travis-ci.org/yeahdongcn/UIColor-Hex-Swift.svg?branch=master)](https://travis-ci.org/yeahdongcn/UIColor-Hex-Swift) [![codecov.io](https://codecov.io/gh/yeahdongcn/UIColor-Hex-Swift/branch/master/graphs/badge.svg)](https://codecov.io/gh/yeahdongcn/UIColor-Hex-Swift/branch/master) ![](https://img.shields.io/badge/Swift-5.0-blue.svg?style=flat) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)
=================
Convenience method for creating autoreleased color using RGBA hex string.```swift
// 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.red.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](https://github.com/apple/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](http://cocoapods.org)
Simply add the following lines to your `Podfile`:
```ruby
# required by CocoaPods 0.36.0.rc.1 for Swift Pods
use_frameworks!pod 'UIColor_Hex_Swift', '~> 5.1.9'
```Then import it where you use it:
```swift
import UIColor_Hex_Swift
```*(CocoaPods v0.36 or later required. See [this blog post](http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/) for details.)*
### [Carthage](http://github.com/Carthage/Carthage)
Simply add the following line to your `Cartfile`:
```ruby
github "yeahdongcn/UIColor-Hex-Swift" >= 5.1.9
```Then add the HexColor.framework to your frameworks list in the Xcode project.
Then import it where you use it:
```swift
import HEXColor
```---
See more in [RSBarcodes_Swift](https://github.com/yeahdongcn/RSBarcodes_Swift) and [objc version](https://github.com/yeahdongcn/RSBarcodes)