Giter Site home page Giter Site logo

muyuto / hexcolors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrs-/hexcolors

0.0 2.0 0.0 168 KB

HexColors is an extension for UIColor and NSColor to support for creating colors from a hex strings

License: MIT License

Objective-C 5.87% Swift 89.39% Ruby 4.73%

hexcolors's Introduction

HexColors

========================= [![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20macOS-lightgrey.svg)](https://github.com/mrs-/HexColors) [![Xcode](https://img.shields.io/badge/Xcode-8.0-blue.svg)](https://developer.apple.com/xcode) [![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg)](https://swift.org) ![Downloads Month](https://img.shields.io/cocoapods/dm/HexColors.svg) ![Cocoapods](https://cocoapod-badges.herokuapp.com/v/HexColors/badge.png) [![Build Status](https://travis-ci.org/mRs-/HexColors.svg?branch=master)](https://travis-ci.org/mrs-/HexColors) [![codecov](https://codecov.io/gh/mRs-/HexColors/branch/master/graph/badge.svg)](https://codecov.io/gh/mRs-/HexColors)

HexColors is an extension for UIColor and NSColor to support for creating colors from a hex string like #FF0088 or 8844FF and back to a String. Completely rewritten in Swift 3!

If you want to use this in Objective-C jump to the 4.X version tag.

#RELEASE 5.0.1 Copy paste Typo Fixxed.

#Examples How to use HexColors in the different systems.

##iOS / watchOS / tvOS

Generating UIColors

let colorWithHex = UIColor("#ff8942")
let colorWithoutHex = UIColor("ff8942")
let colorWithHexAndAlhpa = UIColor("#ff8942DF")
let colorWithoutHexAndAlhpa = UIColor("ff8942DF")
let shortColorWithHex = UIColor("#fff")
let shortColorWithoutHex = UIColor("fff")
let shortColorWithHexAndAlpha = UIColor("#FFFD")
let shortColorWithoutHexAndAlpha = UIColor("#FFFD")

Generating Hex Strings from UIColor

let colorWithHex = UIColor("#ff8942")
let stringFromColor = colorWithHex.hex

##macOS

Generating NSColor

let colorWithHex = NSColor("#ff8942")
let colorWithoutHex = NSColor("ff8942")
let colorWithHexAndAlhpa = NSColor("#ff8942DF")
let colorWithoutHexAndAlhpa = NSColor("ff8942DF")
let shortColorWithHex = NSColor("#fff")
let shortColorWithoutHex = NSColor("fff")
let shortColorWithHexAndAlpha = NSColor("#FFFD")
let shortColorWithoutHexAndAlpha = NSColor("#FFFD")

Generating Hex Strings from NSColor

let colorWithHex = NSColor("#ff8942")
let stringFromColor = colorWithHex.hex

#Installation

##Requirements HexColors requires >= iOS 8.0 and >=macOS 10.9.

Cocoapods

Add HexColors to your Podfile:

pod 'HexColors'
  • pod install HexColors

Carthage

Add HexColors to your Cartfile:

github "mRs-/HexColors"

Swift Package Manager

To work with the Swift Package Manager you need to add a Package.swift file and defining your package.

import PackageDescription

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .Package(url: "https://github.com/mRs-/HexColors", majorVersion: 5),
    ]
)

Then execute the Swift Package Manager with the following Shell commands:

swift build
.build/debug/YourPackageName

Manual

Simply just drag and drop the HexColors.swift in your project.

#Credits HexColors was created by Marius Landwehr because of the pain to create Colors from a API (mostly hex) converting to a UI/NSColor.

#Creator Marius Landwehr @mariusLAN

#License HexColors is available under the MIT license. See the LICENSE file for more info.

hexcolors's People

Contributors

mrs- avatar holgersindbaek avatar chrene avatar andreaskaltenbach avatar cemaleker avatar cbrulak avatar cormacrelf avatar dlinsin avatar chocochipset avatar revolter avatar buscarini avatar mludi avatar troyharris avatar zackliston avatar

Watchers

钱塘江木鱼 avatar James Cloos 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.