Giter VIP home page Giter VIP logo

dtgradientbutton's Introduction

DTGradientButton

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

CocoaPods

Add the following line to your Podfile:

pod 'DTGradientButton'

Swift package manager

DTGradientButton is available for SPM from version 0.1.3. Add the following to the dependencies of your Package.swift:

.package(url: "https://github.com/tungvoduc/DTGradientButton", from: "version")

Author

Tung Vo, [email protected]

License

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

Feedbacks & requests

  • Open an issue if you find a bug, make a proposal or simply need some help.
  • You can also contact me via email.

dtgradientbutton's People

Contributors

tungvoduc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dtgradientbutton's Issues

cornerRadius and shadow BUG

There is a bug when i use button.layer.masksToBounds = false
I cant set it to true and use cornerRadius
so I must set as false to use cornerRadius and shadowColor together

code (objective-c):

    self.button.layer.cornerRadius = 30;
    self.button.layer.shadowOffset = CGSizeMake(0, 10);
    self.button.layer.shadowColor = [UIColor blackColor].CGColor;
    self.button.layer.shadowRadius = 20;
    self.button.layer.shadowOpacity = 0.5f;
    self.button.layer.masksToBounds = NO;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.