该框架提供了一个底部表单视图控制器,可以初始化来托管任何视图或视图控制器。
Y—BottomSheet 使用 Apache 2.0 许可证。
文档由源代码注释自动生成,并作为静态网站托管在 GitHub Pages 上:https://yml-org.github.io/ybottomsheet-ios/
底部表单控制器可以使用标题和视图,或者使用视图控制器进行初始化。
使用视图控制器初始化时,标题从 UIViewController.title
中获取。当视图控制器是 UINavigationController
时,标题栏外观选项将被忽略,导航控制器的导航栏将显示为表单的标题。在这种情况下,如果您希望显示关闭按钮,则应使用视图控制器的 navigationItem.rightBarButtonItem
或 .leftBarButtonItem
进行设置。
两种初始化器都包含一个外观参数,允许您完全自定义表单的外观。您也可以随时更新表单的外观。
import YBottomSheet
final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
showBottomSheet()
}
func showBottomSheet() {
let yourView = UIView()
let sheet = BottomSheetController(
title: "Title",
childView: yourView
)
present(sheet, animated: true)
}
}
import YBottomSheet
final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
showBottomSheet()
}
func showBottomSheet() {
let yourViewController = UIViewController()
let sheet = BottomSheetController(
childController: yourViewController
)
present(sheet, animated: true)
}
}
BottomSheetController
具有类型为 Appearance
的 appearance
属性。
Appearance
允许您自定义底部表单的外观和行为。您可以自定义:
更新或自定义外观
// Declare a resizable sheet.
let sheet = BottomSheetController(
childController: yourViewController,
appearance: .defaultResizable
)
// Change corner radius, remove dimmer,
// and use a shadow instead.
sheet.appearance.layout.cornerRadius = 24
sheet.appearance.dimmerColor = nil
sheet.appearance.elevation = Elevation(
xOffset: 0,
yOffset: 4,
blur: 16,
spread: 0,
color: .black,
opacity: 0.4
)
sheet.appearance.presentAnimation = Animation(
duration: 0.4,
curve: .spring(damping: 0.6, velocity: 0.4)
)
// Present the sheet with a spring animation.
present(sheet, animated: true)
Y—BottomSheet 依赖于我们的 Y—CoreUI 和 Y—MatterType 框架(两者也是开源的,并使用 Apache 2.0 许可证)。
您可以通过将 Y—BottomSheet 添加为包依赖项来将其添加到 Xcode 项目中。
brew install swiftlint
sudo gem install jazzy
克隆存储库并在 Xcode 中打开 Package.swift
。
我们采用 语义版本控制。
{major}.{minor}.{patch}
例如
1.0.5
我们为我们的框架使用简化的分支策略。
main
main
分支出来main
。main
都会被标记为更新的版本号feature/{ticket-number}-{short-description}
bugfix/{ticket-number}-{short-description}
例如
feature/CM-44-button
bugfix/CM-236-textview-color
在提交拉取请求之前,您应该:
swiftlint
并确认没有违规。jazzy
并确认您拥有 100% 的文档覆盖率。git rebase -i HEAD~{commit-count}
将您的最后 {commit-count} 个提交合并到功能块中。main
)的 HEAD 已更新,请使用 git rebase main
来重新设置您的分支。提交拉取请求时
合并拉取请求时
1.0.5
)您可以使用以下来自 Terminal 的命令,直接从源代码生成您自己的本地文档集
jazzy
这将在 /docs
下生成一组文档。默认配置在默认配置文件 .jazzy.yaml
文件中设置。
要查看其他文档选项,请输入
jazzy --help
每次将提交推送到 main
时,GitHub Action 会自动运行 Jazzy 来为我们的 GitHub 页面生成文档:https://yml-org.github.io/ybottomsheet-ios/