BottomCardView
BottomCardView 是一个基于 UIView 用 Swift 编写的视图
POP 进行动画
并且使用要求
BottomCardView 用 Swift 5 编写,兼容 iOS 11.0+。
安装
Cocoapods
pod 'BottomCardView'
Carthage
github "EvgeniyGulkov/BottomCardView"
用法
配置
您可以使用此视图作为简单的 `UIView`,使用界面构建器或通过编程方式添加。
用法示例
import BottomCardView
class ViewController: UIViewController, BottomCardViewDelegate {
@IBOutlet weak var bottomCardView: BottomCardView!
@IBOutlet weak var tableViewInBottom: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
setupBottomCard()
}
func setupBottomCard() {
/// add point (value from bottom)
bottomCardView.addPoint(value: 400)
/// if you want to use top of your screen or top safe area inset as top point,
/// you should add point greater or equal your screen height. for example .infinity
bottomCardView.addPoint(value: .infinity)
/// set minimum point from bottom
bottomCardView.minPoint = 30
/// set delegate
bottomCardView.delegate = self
/// if you want to scroll BottomCardView when scrollView inside
/// is scrolled to end, you should add it with following method
bottomCardView.addScroll(for: tableViewInBottom)
}
您可以通过编程方式更改高度。
bottomCardView.changeHeight(value: 100, animation: .basic(duration: 0.2)) { animation, complete in
}
/// change by point index
bottomCardView.moveToPoint(index: 1, animation: .spring) { animation, complete in
}
您还可以选择动画类型。
- 无(无动画)
- 弹簧(具有默认参数的弹簧动画)
- 基本(无弹簧动画,但可以更改持续时间)
更改默认弹簧动画属性
bottomCardView.bounces = 4
bottomCardView.animationSpeed = 20
设置安全区域内边距
override func viewDidLayoutSubviews() {
bottomCardView.insets = view.safeAreaInsets
}
跟踪高度
您可以使用专门的代理方法跟踪高度和位置。
func bottomCardView(progressDidChangeFromPoint index: Int, toPoint nextIndex: Int, withProgress progress: CGFloat)
func bottomCardView(viewHeightDidChange height: CGFloat)
作者
@EvgeniyGulkov, [email protected]
许可协议
BottomCardView遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。