Git Product home page Git Product logo

swifthexcolors's Introduction

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", majorVersion: 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

iOS 8.0 or above.

License

MIT

swifthexcolors's People

Contributors

thii avatar retsohuang avatar evgeniyd avatar andrewsb avatar danipralea avatar jmper1 avatar joubin avatar mcrollin avatar readmecritic avatar honcheng avatar

Watchers

James Cloos avatar Viktoras Laukevičius avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.