一个显示浮动底部 sheet 的库。
请参阅托管在 Swift Package Index 上的 FloatingBottomSheet DocC 文档。
FloatingBottomSheet 需要 iOS 11+ 版本,并兼容 Swift 5 项目。
安装 FloatingBottomSheet 的首选方式是通过 Swift Package Manager
https://github.com/OhKanghoon/FloatingBottomSheet
) 并点击 Next。# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'FloatingBottomSheet'
end
替换 YOUR_TARGET_NAME
,然后在 Podfile
目录中,输入
$ pod install
要使用 FloatingBottomSheet,你的 ViewController 必须遵循 FloatingBottomSheetPresentable
协议。
首先实现 bottomSheetScrollable
和 bottomSheetHeight
属性。
final class ViewController: UIViewController, FloatingBottomSheetPresentable {
var bottomSheetScrollable: UIScrollView? {
// Return a scrollable view
}
var bottomSheetHeight: CGFloat {
// Set the height of the bottom sheet
}
}
只需使用 presentFloatingBottomSheet 函数即可呈现浮动底部 sheet,如下所示
let viewController = ViewController()
presentFloatingBottomSheet(viewController)
要在运行时动态更新底部 sheet 的高度,请使用以下代码
bottomSheetHeight = 400.0
bottomSheetPerformLayout(animated: true)
你可以将 bottomSheetHeight 的值更改为你想要的高度,然后调用 bottomSheetPerformLayout
函数以更新底部 sheet 的高度,并可选择动画。
如果你不想要动画,请将 animated
设置为 false。
FloatingBottomSheet 基于 MIT 许可。有关更多信息,请参阅 LICENSE。