https://github.com/knottx/hexcolorext
Hex Color Extension. available on CocoaPods.
https://github.com/knottx/hexcolorext
cocoapods extension hex-codes hexcolor ios pod swift uicolor uicolor-extension
Last synced: 4 months ago
JSON representation
Hex Color Extension. available on CocoaPods.
- Host: GitHub
- URL: https://github.com/knottx/hexcolorext
- Owner: knottx
- License: mit
- Created: 2021-02-07T05:19:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-27T06:15:20.000Z (over 5 years ago)
- Last Synced: 2026-02-17T22:22:44.774Z (4 months ago)
- Topics: cocoapods, extension, hex-codes, hexcolor, ios, pod, swift, uicolor, uicolor-extension
- Language: Swift
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**HexColorExt** is an extension for handling color in Swift.
## 📲 Installation
`HexColorExt` is available on [CocoaPods](https://cocoapods.org/pods/HexColorExt):
```ruby
pod 'HexColorExt'
```
## 📝 How
### Code Implementation
```swift
import HexColorExt
```
### Generating UIColors
Wiith first "#" Hex Codes
```swift
let orangeColor = UIColor(hex: "#f60") // short hex
let blueColor = UIColor(hex: "#0080FF")
let blueColorWithAlpha = UIColor(hex: "#0080ff80")
```
Without first "#" Hex Codes
```swift
let orangeColor = UIColor(hex: "f60") // short hex
let blueColor = UIColor(hex: "0080FF")
let blueColorWithAlpha = UIColor(hex: "0080ff80")
```
With Alpha Component
```swift
let orangeColor = UIColor(hex: "f60").withAlpha(0.8)
let blueColor = UIColor(hex: "0080FF").withAlpha(0.6)
```
### Generating Hex Strings from UIColor
```swift
let blueColor = UIColor(hex: "0080FF")
let hex = blueColor.toHex() // "0080FF"
let blueColorWithAlpha = UIColor(hex: "0080ff80")
let hexWithAlpha = blueColor.toHex(alpha: true) // "0080ff80"
```
### Generating UIImage from UIColor
```swift
let blueImage:UIImage = UIColor(hex: "0080FF").image()
```
## 📋 Requirements
* iOS 10.0+
* Xcode 11+
* Swift 5.1+