ios - 与控制中心相同的当前 ViewController 在 iPhone 中工作
问题描述
我想在单击按钮时以所附屏幕截图中显示的方式显示底部工作表。
- 有透明背景
- 可交换的关闭底片
- 当我们向下/向上滑动控制中心菜单时,我通常会注意到顶部的矩形栏图标
我熟悉正常的当前屏幕,即使是透明背景。但是,我真的不确定如何实现这个 UI。因此,我没有附加任何代码,因为我仍在寻找它。任何帮助表示赞赏!谢谢!
解决方案
考虑使用 FloatingPanel
查看这个 GitHub 项目: https ://github.com/scenee/FloatingPanel
let = FloatingPanelController()
let contentVC = YOUR_VIEW_CONTROLLER()
floatingPanel.set(contentViewController: contentVC)
self.present(floatingPanel, animated: true, completion: nil)
让它可以通过向下滑动来移除
floatingPanel.isRemovalInteractionEnabled = true
要自定义浮动面板,您需要使用“浮动面板布局”协议实现布局
class ViewController: UIViewController, FloatingPanelControllerDelegate {
... {
floatingPanel = FloatingPanelController(delegate: self)
floatingPanel.layout = MyFloatingPanelLayout()
}
}
class MyFloatingPanelLayout: FloatingPanelLayout {
let position: FloatingPanelPosition = .bottom
let initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea),
.tip: FloatingPanelLayoutAnchor(absoluteInset: 44.0, edge: .bottom, referenceGuide: .safeArea),
]
}
}
推荐阅读
- node.js - 如何在 AWS Lambda 函数中使用 ImageMagick `drawtext` 方法?
- javascript - 没有 JS 的 SPA 路由使用 @document
- python - 如何更新 Python 实例属性
- flutter - 如何从一页转到另一页?
- javascript - 如何在表单提交之前更改表单操作
- javascript - 如何在画布填充文本中实现自动换行和回车?
- angular - 如何从我的 REST API 的所有页面获取数据?
- javascript - 仅使用 JavaScript 将两个包含逗号和小数的文本字段一起添加
- node.js - 为什么我的快递应用启动后立即关闭?
- azure-devops - 如何在 Azure DevOps 链接中不包含“version=GBmaster”