Skip to content

roydenrego/GradientButtonSwift

Repository files navigation

GradientButtonSwift

A iOS Swift library for Gradient Button.

Swift Version License CocoaPods Compatible Platform PRs Welcome

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

  1. Download and drop GradientButton.swift in your project.
  2. Congratulations!

Usage example

You can create a Gradient Button by

By using Storyboard or XIB

  1. Add button object and set custom class GradientButton

via Storyboard

  1. You can set the gradient colors and corner radius in the Attributes Inspector

via 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 – @roydenregoroydenrego@softrixz.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/roydenrego/GradientButtonSwift