ScalingGradientAnimatedButton 0.1.1

ScalingGradientAnimatedButton 0.1.1

Antonio Ruffolo 维护。



ScalingGradientAnimatedButton

Version License Platform

概览

ScalingGradientAnimatedButton 是 UIView 的子类,用 Swift 编写,会在视图中包括了渐变和缩放动画。

示例

要运行示例项目,首先克隆仓库,然后在示例目录中运行 pod install

需求

  • iOS 8
  • Swift 4.0

安装

ScalingGradientAnimatedButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ScalingGradientAnimatedButton'

使用方法

包括四个初始化函数,提供足够的定制选项。

import ScalingGradientAnimatedButton

/// then inside the viewDidLoad or any view controller with a reference to the view

// init the button with two different colors for the selected and the unselected state, their transition can be animated or not
button.initButton(opacity: 1.0, color: UIColor.black, selectedColor: UIColor.cyan, buttonScale: 0.6, animationDuration: 0.5, shadowOpacity: 0.4, shadowRadius: 1.0, shouldHaveSelectedColorAnimation: true)

// init the button with just one color, only the scale will be animated
button.initButton(opacity: 1.0, color: UIColor.cyan, buttonScale: 1.3, animationDuration: 0.5, shadowOpacity: 0.6, shadowRadius: 1.0)

设置按钮位置以锚定其动画

button.buttonPosition = .left

要截获到达按钮的事件,分配此闭包,它将视图的标签作为参数传递。您可以从 storyboard 中设置标签。

button.calculatorButtonEvent = { tag in
print("Tap or long press received")
}

作者

Antonio Ruffolo

许可证

ScalingGradientAnimatedButton 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。