DTGradientButton 0.1.3

DTGradientButton 0.1.3

Tung Vo维护。



  • 作者:
  • tungvoduc

DTGradientButton

Version License Platform

截图


示例

要运行示例项目,请克隆仓库,然后首先从Example目录运行pod install

使用

要将渐变颜色作为按钮的背景,只需像下面这样做

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

方法setGradientBackgroundColors(_ colors:, direction:, for state:)作为UIButton的扩展方法提供。因此,您可以在项目中使用任何UIButton实例。

支持八种预定义的渐变方向。

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

除了为UIButton设置渐变背景之外,您还可以利用这个库创建以下渐变图像

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

要求

iOS 8.0

安装

CocoaPods

在您的 Podfile 中添加以下行

pod 'DTGradientButton'

Swift package manager

DTGradientButton 从版本 0.1.3 起可在 SPM 中使用。将以下内容添加到您的 Package.swift 的依赖项中

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

作者

Tung Vo, [email protected]

许可证

DTGradientButton 可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。

反馈与请求

  • 如果您发现错误,提出建议或需要帮助,请开启一个issue。
  • 您也可以通过电子邮件联系我。