A lightweight gradient view for iOS 7+, written in Swift, with support for Auto Layout and Interface Builder.
Create a gradient view using the designated initializer.
let gradientView = GradientView(topColor: UIColor.cyanColor(), bottomColor: UIColor.blueColor())
Change colors after initialization:
gradientView.topColor = UIColor.yellowColor()
gradientView.bottomColor = UIColor.orangeColor()
Change the colors of the CAGradientLayer directly:
gradientView.gradientLayer.colors = [UIColor.redColor().CGColor, UIColor.orangeColor().CGColor, UIColor.yellowColor().CGColor]
Drag a View object to the Interface Builder canvas, and change the Class in the Identity inspector:
Then change the colors in the Attributes inspector:
Demo project requires iOS 8+, though BRYXGradientView works on iOS 7+
BRYXGradientView is available through CocoaPods and Carthage.
Adam Binsz, adam@adambinsz.com
BRYXGradientView is available under the MIT license. See the LICENSE file for more info.