Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thii/SwiftHEXColors
HEX color handling as an extension for UIColor.
https://github.com/thii/SwiftHEXColors
Last synced: about 2 months ago
JSON representation
HEX color handling as an extension for UIColor.
- Host: GitHub
- URL: https://github.com/thii/SwiftHEXColors
- Owner: thii
- License: mit
- Created: 2014-10-04T13:10:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-10-05T19:03:31.000Z (over 2 years ago)
- Last Synced: 2024-05-02T01:11:37.205Z (9 months ago)
- Language: Swift
- Homepage:
- Size: 203 KB
- Stars: 692
- Watchers: 28
- Forks: 97
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - SwiftHEXColors - HEX color handling as an extension for UIColor. (Color / Linter)
- awesome-swift - SwiftHEXColors - HEX color handling as an extension for UIColor. (Libs / Colors)
- awesome-swift - SwiftHEXColors - HEX color handling as an extension for UIColor. (Libs / Colors)
- fucking-awesome-swift - SwiftHEXColors - HEX color handling as an extension for UIColor. (Libs / Colors)
- awesome-ios-star - SwiftHEXColors - HEX color handling as an extension for UIColor. (Color / Linter)
- awesome-swift-cn - SwiftHEXColors - HEX color handling as an extension for UIColor. (Libs / Colors)
- fucking-awesome-ios - SwiftHEXColors - HEX color handling as an extension for UIColor. (Color / Linter)
- fucking-awesome-ios - SwiftHEXColors - HEX color handling as an extension for UIColor. (Color / Linter)
- awesome-swift - SwiftHEXColors - HEX color handling as an extension for UIColor. ` 📝 8 months ago ` (Colors [🔝](#readme))
README
SwiftHEXColors
===========[![Build Status](http://img.shields.io/travis/thii/SwiftHEXColors.svg?style=flat)](https://travis-ci.org/thii/SwiftHEXColors)
[![Swift Package Manager Compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg?style=flat)](https://github.com/apple/swift-package-manager)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftHEXColors.svg)](https://img.shields.io/cocoapods/v/SwiftHEXColors.svg)
[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/SwiftColors.svg)](http://cocoadocs.org/docsets/SwiftHEXColors)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Platform](https://img.shields.io/cocoapods/p/SwiftHEXColors.svg?style=flat)](http://cocoadocs.org/docsets/SwiftHEXColors)
[![License](https://img.shields.io/cocoapods/l/SwiftHEXColors.svg)](https://raw.githubusercontent.com/thii/SwiftHEXColors/master/LICENSE)HEX color handling as an extension for UIColor. Written in Swift.
## Examples
### iOS
``` swift
// With hash
let color: UIColor = UIColor(hexString: "#ff8942")// Without hash, with alpha
let secondColor: UIColor = UIColor(hexString: "ff8942", alpha: 0.5)// Short handling
let shortColorWithHex: UIColor = UIColor(hexString: "fff")
```For those who don't want to type the double quotation, you can init a color from a real hex value (an `Int`)
```swift
// With hash
let color: UIColor = UIColor(hex: 0xff8942)// Without hash, with alpha
let secondColor: UIColor = UIColor(hex: 0xff8942, alpha: 0.5)
```### OSX
``` swift
// With hash
let color: NSColor = NSColor(hexString: "#ff8942")// Without hash, with alpha
let secondColor: NSColor = NSColor(hexString: "ff8942", alpha: 0.5)// Short handling
let shortColorWithHex: NSColor = NSColor(hexString: "fff")// From a real hex value (an `Int`)
// With hash
let color: NSColor = NSColor(hex: 0xff8942)// Without hash, with alpha
let secondColor: NSColor = NSColor(hex: 0xff8942, alpha: 0.5)
```## Installation
### Swift Package Manager
Add this as a dependency in your `Package.swift`:
```swift
import PackageDescriptionlet package = Package(
name: "MyPackage",
dependencies: [
// Other dependencies
.package(url: "https://github.com/thii/SwiftHEXColors.git", from: "1.3.1")
]
)
```### CocoaPods
To integrate SwiftHEXColors into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!pod 'SwiftHEXColors'
```Then, run the following command:
```bash
$ pod install
```And add `import SwiftHEXColors` to the top of the files using SwiftHEXColors.
### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```To integrate SwiftHEXColors into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "thii/SwiftHEXColors"
```Run `carthage update` to build the framework and drag the built `SwiftHEXColors.framework` into your Xcode project.
### Manually
- Drag and drop `SwiftHEXColors.swift` file into your project# Requirements
- Swift 3
- iOS 8.0 or above.# License
[MIT](http://thi.mit-license.org/)