GithubHelp home page GithubHelp logo

icodesign / swiftcolor Goto Github PK

View Code? Open in Web Editor NEW
51.0 5.0 18.0 66 KB

A Swift Extension for UIColor.

Home Page: https://github.com/icodesign/SwiftColor

License: MIT License

Swift 94.85% Ruby 5.15%

swiftcolor's Introduction

License platform Build Status codecov

A Swift Extension for UIColor supporting iOS/watchOS/tvOS and macOS.

Installation

Swift Package Manager

.package(url: "https://github.com/icodesign/SwiftColor.git", from: "1.5.0")

Carthage

Add SwiftColor to your Cartfile:

github "icodesign/SwiftColor"

CocoaPods

Add SwiftColor to your Podfile:

pod 'SwiftColor'

Manually

You can also integrate SwiftColor directly with souce code. Just copy SwiftColor.swift to your project.

Usage

Color Initialization

SwiftColor provides a typealias for UIColor/NSColor as Color.

Initialize with Hex String

Supported hex string format: RGB, RGBA, [0x|#]RRGGBB, [0x|#]RRGGBBAA

Color("000")
Color("000C")
Color("0x4DA2D9")
Color(hexString: "#4DA2D9")
Color(hexString: "#4DA2D9CC")

Color(hexString: "#4DA2D9", alpha: 0.8)

"#4DA2D9CC".color

Initialize with Hex Int

Only hex format 0xRRGGBB is supported

Color(hexInt: 0x4DA2D9)

Color(hexInt: 0x4DA2D9, alpha: 0.8)

(0x4DA2D9).color

Initialize with RGBA

Color(byteRed: 77, green: 162, blue: 217, alpha: 0.8)

Get/Change Color Components

let color = Color(hexString: "#4DA2D9CC")

// get color components
var (r, g, b, a) = color.colorComponents()

// change color components
var red = "000".color.red(255)
var alphaColor = Color(hexInt: 0x4DA2D9).alpha(0.8)

Convert color to image

let image = "000".color.toImage()

swiftcolor's People

Contributors

icodesign avatar whlsxl avatar

Stargazers

Ferris avatar  avatar  avatar StephenFang avatar  avatar walter iOS avatar  avatar xiao fang avatar GAURAV avatar  avatar clyde avatar Larry Zhang avatar Abdullah Al Mashmoum avatar YanBiao avatar Aiolia.Coco avatar err avatar  avatar PING avatar Lee avatar Wymany Wu avatar newbie avatar zw avatar Frank avatar Jeffrey Macko avatar Raul Silva avatar Toseef Khilji avatar Steve avatar zhangzhijie avatar Marius Waldal avatar Yubo Qin avatar LXF avatar Rohit Gupta avatar Sourav Chandra avatar  avatar Tarvo R. avatar Alexander Murphy avatar Jeongyeon Park avatar Steve Kim avatar  avatar Feng Qiang avatar  avatar  avatar Quinn avatar Luke Luo avatar Lee Probert avatar Joseph Khawly avatar Xavier Schott avatar Kris Haamer avatar  avatar Pierre Rougeot avatar  avatar

Watchers

James Cloos avatar  avatar Xavier Schott avatar  avatar  avatar

swiftcolor's Issues

Swift 2.3 support

Hi,

I have a fork which adds 2.3 support, would you consider creating a 2.3 branch so I can create a PR with my changes? Although to be honest the change is a single character, but I thought I'd contribute what I could :)

Thanks,
Noah

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.