BottomCard
BottomCard 是基于UIView并用Swift编写的视图
POP 进行动画
并使用需求
BottomCard是用Swift 5编写的。兼容iOS 11.0以上。
安装
Cocoapods
pod 'BottomCard'
Carthage
github "EvgeniyGulkov/BottomCard"
使用方法
设置
可以使用这个视图作为简单的UIView,使用界面构建器或以编程方式添加。您可以添加尽可能多的点。最高点值是bottomCardView的高度限制。
使用示例
import BottomCard
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
}
从顶部使用
bottomCardView.side = .top
跟踪高度
您可以使用专用的委托方法跟踪高度和位置
func bottomCardView(progressDidChangeFromPoint index: Int, toPoint nextIndex: Int, withProgress progress: CGFloat)
func bottomCardView(viewHeightDidChange height: CGFloat)
跟踪动画
您还可以使用委托方法跟踪动画
func bottomCardView(popAnimationDidStart animation: POPAnimation)
func bottomCardView(popAnimationDidApply animation: POPAnimation)
func bottomCardView(popAnimationDidReach animation: POPAnimation)
func bottomCardView(popAnimationDidStop animation: POPAnimation, finished: Bool)
作者
@EvgeniyGulkov,[email protected]
许可证
BottomCard 使用 MIT 许可证。更多信息请参阅 LICENSE 文件。