DTZFloatingActionButton
Swift 中的浮动按钮。
需求
- iOS 9.0+
- Swift 4.0
- Xcode 9
安装
CocoaPods
DTZFloatingActionButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'DTZFloatingActionButton'
手动
手动安装DTZFloatingActionButton的应用程序,只需将DTZFloatingActionButton/Classes/*.swift
文件拖入您的项目中。
用法
作为UIWindow的管理员
DTZFABManager.shared.button().handler = {
button in
print("Tapped")
}
DTZFABManager.shared.show()
在UIView中
let actionButton = DTZFloatingActionButton()
actionButton.handler = {
button in
self.performSegue(withIdentifier: "tableViewSegue", sender: nil)
}
self.view.addSubview(actionButton)
在UITableView, UICollectionView中
let actionButton = DTZFloatingActionButton()
actionButton.handler = {
button in
print("Hi!")
}
actionButton.isScrollView = true
self.view.addSubview(actionButton)
自定义初始化器
let actionButton = DTZFloatingActionButton(frame:CGRect(x: view.frame.size.width - 56 - 14,
y: view.frame.size.height - 56 - 14,
width: 56,
height: 56
))
类似于谷歌地图中的按钮
paddingX = 10
paddingY = 76
buttonColor = .white
buttonImage = UIImage(named: "icons8-layers-50")
plusColor = .darkGray
shadowCircleColor = .black
shadowCircleOffSet = CGSize(width: 0, height: 2)
shadowCircleOpacity = 0.4
shadowCircleRadius = 2
isAddShadow = true
例子
要运行示例项目,首先克隆仓库,然后在示例目录中运行pod install
。
作者
Evgeny Dats (hintoz), [email protected]
许可协议
DTZFloatingActionButton 在 MIT 许可协议下可用。更多信息请参阅 LICENSE 文件。