UIGradient alternatives and similar libraries
Based on the "Colors" category.
Alternatively, view UIGradient alternatives based on common mentions on social networks and blogs.
-
Chameleon
Color framework for Swift & Objective-C (Gradient colors, hexcode support, colors from images & more). -
SwiftGen-Colors
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
Hue
:art: Hue is the all-in-one coloring utility that you'll ever need. -
DynamicColor
Yet another extension to manipulate colors easily in Swift and SwiftUI -
UIColor-Hex-Swift
Convenience methods for creating color using RGBA hex string. -
SwiftHEXColors
HEX color handling as an extension for UIColor. -
Gradients
🌔 A curated collection of splendid 180+ gradients made in swift -
ChromaColorPicker
:art: An intuitive iOS color picker built in Swift. -
RandomColorSwift
An attractive color generator for Swift. Ported from randomColor.js. -
PrettyColors
Styles and colors text in the Terminal with ANSI escape codes. Conforms to ECMA Standard 48. -
HexColor
Utility that lets you define UIColors in Swift as they've meant to be defined: as HEX values -
AEConicalGradient
Conical (angular) gradient for iOS written in Swift -
ImagePalette
Swift/iOS port of Android's Palette https://developer.android.com/reference/android/support/v7/graphics/Palette.html -
UIColor-WikiColors
All wikipedia colors implemented as easy to use UIColor extension 🌈 -
Google Material Color
Google Material Color Palette in Swift -
Colors
A pure Swift library for using ANSI codes. Basically makes command-line coloring and styling very easy!
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of UIGradient or a related project?
README
Installation
UIGradient is now available on CocoaPods. Simply add the following to your project Podfile, and you'll be good to go.
pod 'UIGradient'
Usage
GradientLayer
Create a GradientLayer then add it to your view's
public extension UIView {
func addGradientWithDirection(_ direction: GradientDirection, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil)
func addGradient(_ gradientLayer: GradientLayer, cornerRadius: CGFloat = 0)
}
Example
let gradient = GradientLayer(direction: GradientDirection, colors: [UIColor])
view.addGradient(gradient)
UIGradient supports those directions below:
public enum GradientDirection {
case topToBottom // top to bottom
case bottomToTop // bottom to top
case leftToRight // left to right
case rightToLeft // right to left
case topLeftToBottomRight // top left to bottom right
case topRightToBottomLeft // top right to bottom left
case bottomLeftToTopRight // bottom left to top right
case bottomRightToTopLeft // bottom right to top left
}
You can also create a GradientLayer clone instance using this function:
open class GradientLayer: CAGradientLayer {
...
public final func clone() -> GradientLayer
...
}
Gradient color
UIGradient allows you create gradient color
public extension UIColor {
static func fromGradient(_ gradient: GradientLayer, frame: CGRect, cornerRadius: CGFloat = 0) -> UIColor?
static func fromGradientWithDirection(_ direction: GradientDirection, frame: CGRect, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil) -> UIColor?
}
Example
let view1 = UIView(frame: frame)
view1.backgroundColor = UIColor.fromGradientWithDirection(.topToBottom, frame: frame, colors: [UIColor.blue, UIColor.green])
//view1.backgroundColor = UIColor.fromGradient(gradient, frame: frame)
let label = UILabel(frame: frame)
label.text = "some text"
label.textColor = UIColor.fromGradient(gradient, frame: frame)
Gradient image
UIGradient also allows you create gradient image
public extension UIImage {
static func fromGradient(_ gradient: GradientLayer, frame: CGRect, cornerRadius: CGFloat = 0) -> UIImage?
static func fromGradientWithDirection(_ direction: GradientDirection, frame: CGRect, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil) -> UIImage?
}
Example
let imageView = UIImageView(frame: frame)
imageView.image = UIImage.fromGradientWithDirection(.bottomLeftToTopRight, frame: frame, colors: [UIColor.blue, UIColor.green])
Gradient library
UIGradient was inspired by @lukedesigner. I created 24 gradients based on his website and make them static variables of GradientLayer so everyone can use those gradients for their projects.
let oceanBlueGradient = GradientLayer.oceanBlue
let sanguineGradient = GradientLayer.sanguine
let lusciousLimeGradient = GradientLayer.lusciousLime
let purpleLakeGradient = GradientLayer.purpleLake
...
You can explore them in my example project.
Author
UIGradient was created by Đinh Quang Hiếu ([email protected]) in 2017 using Swift. If you found any problem please create issue or pull request to help me improve this open source project. Thanks!
License
UIGradient is released and distributed under the terms and conditions of the MIT license.
*Note that all licence references and agreements mentioned in the UIGradient README section above
are relevant to that project's source code only.