Latest 0.1.0
Homepage https://github.com/tungvoduc/DTGradientButton
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Screenshot

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

To set gradient colors as background for a button, just use it as below:

let colors = [UIColor(hex: "FF8960"), UIColor(hex: "FF62A5")]
button.setGradientBackgroundColors(colors, direction: .toRight, for: .normal)

Method setGradientBackgroundColors(_ colors:, direction:, for state:) is provided as an extended method of UIButton. For that reason, you can use it for any UIButton instance in your project.

Eight predefined directions are supported for the gradient.

public enum DTImageGradientDirection {
    case toLeft
    case toRight
    case toTop
    case toBottom
    case toBottomLeft
    case toBottomRight
    case toTopLeft
    case toTopRight
}

Besides setting gradient background for UIButton, you can take advantage of this library to create gradient image as below:

let colors = [UIColor(hex: "FF8960"), UIColor(hex: "FF62A5")]
let image = UIImage(size: CGSize(width: 100, height: 100), direction: .toBottom, colors: colors)

Requirements

iOS 8.0

Installation

DTGradientButton is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DTGradientButton'

Author

tungvoduc, [email protected]

License

DTGradientButton is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DTGradientButton",
    "version": "0.1.0",
    "summary": "Easy way to set gradient background to your buttons.",
    "description": "DTGradientButton provide all UIButton a quick and easy way to set gradient background for each control state. In addition, you can also quickly create gradient image.",
    "homepage": "https://github.com/tungvoduc/DTGradientButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "tungvoduc": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tungvoduc/DTGradientButton.git",
        "tag": "0.1.0"
    },
    "swift_version": "4.0",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "DTGradientButton/Classes/**/*"
}

Pin It on Pinterest

Share This