EMSpinnerButton 是一个有旋转动画的优雅按钮,并且可完全自定义。
灵感来自星巴克应用
目录
功能
- 标题
- 渐变背景(可选)
- 多种动画
- 完全可自定义
- CocoaPods
要求
- iOS 9.0+
- Xcode 9+
安装
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 EMSpinnerButton 集成到您的 Xcode 项目中,在 Podfile 中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'EMSpinnerButton'
end
然后,运行以下命令
$ pod install
使用说明
在故事板上添加一个UIButton,并将其类修改为EMSpinnerButton。
动画效果
折叠
// Collapse animation
button.animate(animation: .collapse)
展开
// Expand animation
button.animate(animation: .expand)
震动
// Shake animation
button.animate(animation: .shake)
自定义
按钮标题
button.title = "LOGIN"
// Default title = nil
圆角半径
button.cornerRadius = button.frame.height/2
// Default corner radius = 0
标题颜色
button.titleColor = UIColor.red
// Default color = UIColor.white
背景颜色
button.backgroundColor = UIColor.white
// Default color = UIColor(red: 49/255, green: 177/255, blue: 229/255, alpha: 1.0)
背景渐变色
button.gradientColor = UIColor.white
// Default colors = nil
加载器颜色
button.spinnerColor = UIColor.lightGray.cgColor
// Default color = UIColor.white.cgColor
许可
EMSpinnerButton 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。