Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🎨 Hue is the all-in-one coloring utility that you'll ever need.

License

NotificationsYou must be signed in to change notification settings

zenangst/Hue

Repository files navigation

Hue

Hue is the all-in-one coloring utility that you'll ever need.

VersionCarthage CompatibleLicensePlatformSwift

Usage

Hex

Hue IconYou can easily use hex colors with theinit(hex:) convenience initializer onUIColor. It supports the following hex formats#ffffff,ffffff,#fff,fff

letwhite=UIColor(hex:"#ffffff")letblack=UIColor(hex:"#000000")letred=UIColor(hex:"#ff0000")letblue=UIColor(hex:"#0000ff")letgreen=UIColor(hex:"#00ff00")letyellow=UIColor(hex:"#ffff00")

Computed color properties

letwhite=UIColor(hex:"#ffffff")letblack=UIColor(hex:"#000000")if white.isDarkColor{} // return falseif white.isBlackOrWhite{} // return true

Alpha

.alpha is a sugar forcolorWithAlphaComponent, internally it does the exact same thing, think of it as alipstick for your implementation.

letcolorWithAlpha= myColor.alpha(0.75)

Gradients

You can easily create gradient layers using thegradient() method on arrays withUIColor.As an extra bonus, you can also add a transform closure if you want to modify theCAGradientLayer.

letgradient=[UIColor.blackColor(),UIColor.orangeColor()].gradient()letsecondGradient=[UIColor.blackColor(),UIColor.orangeColor()].gradient{ gradientin  gradient.locations=[0.25,1.0]return gradient}

Image colors

letimage=UIImage(named:"My Image")let(background, primary, secondary, detail)= image.colors()

Components

You can get red, green, blue, and alpha components from any UIColor by using the (red|green|blue|alpha)Component property.

letmyColor=UIColor(hex:"#ffafc2")letmyColorBlueComponent= myColor.blueComponentletmyColorGreenComponent= myColor.greenComponentletmyColorRedComponent= myColor.redComponentletmyColorAlphaComponent= myColor.alphaComponent

Blending

letred=UIColor.redColor()letgreen=UIColor.greenColor()letyellow= red.addRGB(green)letdesaturatedBlue=UIColor(hex:"#aaaacc")letsaturatedBlue= desaturatedBlue.addHue(0.0, saturation:1.0, brightness:0.0, alpha:0.0)

Supporting the project

If you want to support the development of this framework, you can do so by becoming asponsor. ❤️

Examples

Hex Example screenshot

Hex

This super simple example that displays a bunch of color schemes in a Carousel view.

It uses hex to set the color for the schemes. It leverages from.isDarkColor to make the text color readable in all scenarios.

The demo also featuresSpots for rendering the Carousel view.

Example code:

letcolor=UIColor(hex:"#3b5998")backgroundColor= colorlabel.textColor= color.isDark?UIColor.whiteColor():UIColor.darkGrayColor()

Gradients

Gradients Example screenshot

This examples shows how much fun you can have with combiningCAGradientLayer withCABasicAnimation.

It uses.hex for getting the colors and.gradient() for transforminga collection ofUIColor's into aCAGradientLayer.

The demo featuresSpots for rendering the list view andFakery for generating random content strings.

Extract from the demo:

lazyvargradient:CAGradientLayer=[UIColor(hex:"#FD4340"),UIColor(hex:"#CE2BAE")].gradient{ gradientin    gradient.speed=0    gradient.timeOffset=0return gradient}

Installation

Hue is available throughCocoaPods. To installit, simply add the following line to your Podfile:

pod'Hue'

Hue is also available throughCarthage.To install just write into your Cartfile:

github"hyperoslo/Hue"

To installHue usingSwift Package Manager with Xcode 11, just follow the instructions athttps://developer.apple.com/documentation/swift_packages and import the platform specific library to the project:

import Hue

Author

Hyper made this with ❤️

Contribute

We would love you to contribute toHue, check theCONTRIBUTING file for more info.

Credits

Credit goes out to Panic Inc who createdColorArt and@jathu for his work onUIImageColors which deeply inspired the functionality behind the image color analysis.

License

Hue is available under the MIT license. See the LICENSE file for more info.

About

🎨 Hue is the all-in-one coloring utility that you'll ever need.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp