特性 • 兼容性 • 安装 • 用法 • 文档 • 贡献 • 作者 • 许可证
阅读我们的 博客,了解 Slack 如何通过 PanModal 获得更多 👍
Swift 4.2 的支持可以在 Swift4.2
分支上找到。
UIViewController
PanModal 需要 iOS 10+ 并且与 Swift 4.2 项目兼容。
pod 'PanModal'
github "slackhq/PanModal"
dependencies: [
.package(url: "https://github.com/slackhq/PanModal.git", .exact("1.2.6")),
],
PanModal 的设计易于使用。 只需像呈现 UIViewController
一样调用 presentPanModal
.presentPanModal(yourViewController)
呈现的视图控制器必须符合 PanModalPresentable
才能利用可自定义的选项
extension YourViewController: PanModalPresentable {
var panScrollable: UIScrollView? {
return nil
}
}
如果呈现的视图控制器有一个嵌入的 UIScrollView
,例如 UITableViewController
,panModal 将在模态框和滚动视图之间无缝过渡平移手势
class TableViewController: UITableViewController, PanModalPresentable {
var panScrollable: UIScrollView? {
return tableView
}
}
可以通过重写 shortFormHeight
或 longFormHeight
来调整 panModal 的高度值
var shortFormHeight: PanModalHeight {
return .contentHeight(300)
}
var longFormHeight: PanModalHeight {
return .maxHeightWithTopInset(40)
}
值在呈现期间存储,因此在运行时调整时,应调用 panModalSetNeedsLayoutUpdate()
func viewDidLoad() {
hasLoaded = true
panModalSetNeedsLayoutUpdate()
panModalTransition(to: .shortForm)
}
var shortFormHeight: PanModalHeight {
if hasLoaded {
return .contentHeight(200)
}
return .maxHeight
}
查看 示例 App,了解 PanModalPresentable
的更复杂配置,包括导航控制器和堆叠模态框。
Option + 单击 PanModal 的任何方法或注释以获取详细文档。
我们很高兴能够开源这个库。 我们在 slack 应用程序中的许多地方都使用它,并希望它易于使用和修改; 我们已在代码中添加了大量文档以支持这一点。
我们将只修复严重错误,因此,对于任何非关键问题或功能请求,我们希望能够依靠使用该库的社区来添加他们需要的内容。 有关更多信息,请阅读 贡献指南。
Stephen Sowole • Tosin Afolabi
PanModal 在 MIT 许可证下发布。 有关详细信息,请参阅 LICENSE 文件。