Gradient View
Easily use gradients in UIKit. Gradient View is a simple UIView wrapper around CGGradient.
Usage
// Initialize a gradient view
let gradientView = GradientView(frame: CGRectMake(x: 20, y: 20, width: 280, height: 280))
// Set the gradient colors
gradientView.colors = [UIColor.greenColor(), UIColor.yellowColor()]
// Optionally set some locations
gradientView.locations = [0.8, 1.0]
// Optionally change the direction. The default is vertical.
gradientView.direction = .Horizontal
// Add some borders too if you want
gradientView.topBorderColor = UIColor.redColor()
gradientView.bottomBorderColor = UIColor.blueColor()
// Add it as a subview in all of its awesome
view.addSubview(gradientView)
See the source for full documentation.
Example
Open up the included Xcode project for an example app.
Installation
Gradient View supports installation with Carthage or CocoaPods. You can also simply add GradientView.swift to your project if you’d prefer.