• Stars
    star
    693
  • Rank 65,262 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HEX color handling as an extension for UIColor.

SwiftHEXColors

Build Status Swift Package Manager Compatible CocoaPods Compatible Docs Carthage Compatible Platform License

HEX color handling as an extension for UIColor. Written in Swift.

Examples

iOS

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

// With hash
let color: UIColor = UIColor(hex: 0xff8942)

// Without hash, with alpha
let secondColor: UIColor = UIColor(hex: 0xff8942, alpha: 0.5)

OSX

// 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:

import PackageDescription

let 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:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'SwiftHEXColors'

Then, run the following command:

$ pod install

And add import SwiftHEXColors to the top of the files using SwiftHEXColors.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SwiftHEXColors into your Xcode project using Carthage, specify it in your Cartfile:

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

More Repositories

1

FontAwesome.swift

Use FontAwesome in your Swift projects
Swift
1,574
star
2

DTTJailbreakDetection

A jailbreak detection library for iOS
Objective-C
283
star
3

aws-codebuild-extras

Add extra information of your AWS CodeBuild build via environment variables.
Shell
150
star
4

Notie

In-app notification in Swift, with customizable buttons and input text field.
Swift
84
star
5

TextEthan

Clone of TextEthan - a messaging app that allows anyone to message you, written in Swift.
Swift
47
star
6

Unxip

A Swift command line tool to extract signed archives (.xip files).
Swift
31
star
7

rules_swiftlint

Run SwiftLint in your Bazel build efficiently.
Starlark
25
star
8

AlertKit

Alert with a single line of Swift.
Swift
21
star
9

iOS8Colors

A category on UIColor which provides you some of the standard colors used throughout iOS 8
Objective-C
10
star
10

thinkpython

Source code with fixes and precompiled EPUB and MOBI of the "Think Python" book
TeX
9
star
11

docker-platex

Docker image for pLaTeX
Shell
8
star
12

rules_apple_extras

Extra Bazel rules for Apple platforms.
C
7
star
13

abbajs

A/B test analysis library in JavaScript
JavaScript
6
star
14

rules_objc

[DEPRECATED] Experimental Starlark implementation of Objective-C rules for Bazel.
Starlark
5
star
15

packup

Scaffold out a Swift package.
Swift
4
star
16

binomjs

A binomial distribution testing library in JavaScript
JavaScript
4
star
17

BINList

BIN lookup library in Swift
Swift
2
star
18

docker-nginx

Blazing fast nginx with latest stable version of nginx, memcached, PHP and HHVM
Nginx
2
star
19

homebrew-swift-runtime

Swift 5 Runtime Support for Command Line Tools
Ruby
2
star
20

CloudFlareDDNS

Dynamic DNS for CloudFlare
Shell
2
star
21

objective-c-style-guide

Objective-Cスタむルガむド
1
star
22

DummyFacebook

Shouldn't you be working?
Swift
1
star
23

HTTPMethod

Just an enum of HTTP request methods.
Swift
1
star
24

signifyd-node

Node.js Client for Signifyd API
CoffeeScript
1
star
25

homebrew-fonts

A custom Cask tap for installing Apple's new San Francisco font use in ο£ΏWatch
Ruby
1
star
26

bug-fixes-and-performance-improvements

Verified localization of "Bug fixes and performance improvements" release notes. Ready to use with fastlane.
Ruby
1
star
27

yes

yes command line tool written in Swift. 60+ times faster than macOS built-in yes.
Swift
1
star
28

docker-swift

A Docker container of Swift built from source from the latest commit on official Swift's repo.
1
star
29

altconf-2019-labs-bazel-starting-point

AltConf 2019 Labs - Fast iOS build with Bazel - Sample project starting point
Makefile
1
star