GradientButtonSwift
A iOS Swift library for Gradient Button.
GradientButtonSwift is a swift library for applying gradients on UIButton for iOS projects. Gradient can be applied by specifying the top and bottom color for the button and the gradient will be automatically applied. It also supports specifying corner radius if you want a nice gradient button with rounded corners.
Requirements
- iOS 9.0+
- Xcode 8.0+
Installation
CocoaPods
You can use CocoaPods to install GradientButtonSwift
by adding it to your Podfile
:
platform :ios, '9.0'
use_frameworks!
pod 'GradientButtonSwift'
To get the full benefits import GradientButtonSwift
wherever you import UIKit
import UIKit
import GradientButtonSwift
Manually
- Download and drop
GradientButton.swift
in your project. - Congratulations!
Usage example
You can create a Gradient Button by
By using Storyboard or XIB
- Add button object and set custom class
GradientButton
- You can set the gradient colors and corner radius in the Attributes Inspector
By using code
import GradientButtonSwift
...
let button = GradientButton(frame: CGRect(x: 10, y: 20, width: 150, height: 40))
button.setTitle("Button", for: .normal)
button.topGradientColor = UIColor.red
button.bottomGradientColor = UIColor.orange
button.cornerRadius = 5
self.view.addSubview(button)
Contribute
We would love you for the contribution to GradientButtonSwift, check the LICENSE
file for more info.
Meta
Royden Rego – @roydenrego – [email protected]
Distributed under the MIT license. See LICENSE
for more information.