ImColorAdjustmenter 0.1.1

ImColorAdjustmenter 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2015
SPMSupports SPM

Maintained by ikemai.



  • By
  • ikemai

ImColorAdjustmenter is the library which can play with the numerical value of the color.

Demo

  • UIColor can regulate numerical value of HBS and RGB of the target color.

Gif Gif

  • UIView can make gradation of Gradation.
  • You can coordinate gradation colors with the number of any colors.

Gif

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

ImColorAdjustmenter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ImColorAdjustmenter"

Example

  • Appoint it in hexadecimal and create UIColor.
let color = UIColor(hex: 0xB7EAE7)
  • Ajustment color of HBS.
let adjustmentColor = color.colorWithHBSComponent(hue: hueValue, brightness: brightnessValue, saturation: saturationValue)
adjustmentColorView.backgroundColor = adjustmentColor
  • Ajustment color of HBS.
let adjustmentColor = color.colorWithHBSComponent(hue: hueValue, brightness: brightnessValue, saturation: saturationValue)
adjustmentColorView.backgroundColor = adjustmentColor
  • Get HBS value of color.
if let hbs = adjustmentColor?.colorHBS() {
    print("Hue = \(hbs.hue)")
    print("Bridhtness = \(hbs.brightness)")
    print("Saturation = \(hbs.saturation)")
}
  • Ajustment color of RGB.
let adjustmentColor = color.colorWithRGBComponent(r: rValue, g: gValue, b: bValue)
targetView.backgroundColor = adjustmentColor
  • Get RGB value of color.
if let rbg = adjustmentColor?.colorRGB() {
    print("Red = \(rbg.r)")
    print("Green = \(rbg.g)")
    print("Blue = \(rbg.b)")
}
  • Create gradation view.
let colors: [CGColor] = [UIColor.whiteColor().CGColor, UIColor.redColor().CGColor]
let locations: [CGFloat] = [0.0, 1.0]
targetView.layerVerticallyGradient(colors: colors, locations: locations)

Function

  • Appoint it in hexadecimal and create UIColor.
public convenience init(hex: Int, alpha: CGFloat = 1)
  • UIColor ajustment color of HBS.
public func colorWithHBSComponent(hue hue: CGFloat, brightness: CGFloat, saturation: CGFloat) -> UIColor?
  • UIColor get HBS value of color.
public func colorHBS() -> ImColorAdjustmenter.HBSProperties?
  • UIColor ajustment color of RGB.
public func colorWithRGBComponent(r r: CGFloat, g: CGFloat, b: CGFloat) -> UIColor?
  • UIColor get RGB value of color.
public func colorRGB() -> ImColorAdjustmenter.RGBProperties?
  • UIView create gradation view.
public func layerVerticallyGradient(colors colors: [AnyObject], locations: [CGFloat])

Properties

  • Value of HBS
public struct HBSProperties {
    public var hue: CGFloat = 0
    public var brightness: CGFloat = 0
    public var saturation: CGFloat = 0
    public var alpha: CGFloat = 1
}
  • Value of RGB
public struct RGBProperties {
    public var r: CGFloat = 0
    public var g: CGFloat = 0
    public var b: CGFloat = 0
    public var alpha: CGFloat = 1
}

Author

ikemai

License

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