Swift 5.x, iOS 15+
EasySideMenu 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile:
pod 'EasySideMenu'
- 文件 > Swift 包 > 添加包依赖
- 添加
https://github.com/tienvv88/EasySideMenu.git
OR
更新 dependencies
中的 Package.swift
dependencies: [.package(url: "[https://github.com/tienvv88/EasySideMenu.git]", .upToNextMajor(from: "0.1.1"))]
classic | rotation3D (flipOutside) | rotation3D (flipInside) | clipToCenter | clipToCorner (bottom) | clipToCorner (top) | pourToLeft | pourToRight |
---|---|---|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install
。
参数 | 值类型 | 默认值 |
---|---|---|
风格 | EasyMenuStyle | .classic |
动画 | 动画 | .snappy(duration: 0.25, extraBounce: 0.1) |
sideMenuWidth | CGFloat | UIScreen.main.bounds.width * 0.5 |
cornerRadius | CGFloat | 25 |
overlayColorWhenOpenMenu | Color | Color.black.opacity(0.3) |
dagToOpenMenu | (isAllow: Bool, startLocation: CGFloat) | (true, 10) |
showMenu | 绑定 | 强制 |
内容 | View | 强制 |
菜单 | View | 强制 |
背景 | View | 强制 |
风格 | 参数 | 值范围 |
---|---|---|
classic | -- | -- |
rotation3D | flip: EasyRotation3DStyle (flipOutside, flipInside) | -- |
pourToRight | -- | -- |
pourToLeft | -- | -- |
clipToCorner | side: EasyClipToCorner (top, bottom), offsetY | offsetY: 100 - (UIScreen.main.bounds.width / 2) |
clipToCenter | contentHeight: CGFloat | contentHeight: (UIScreen.main.bounds.height / 3) - UIScreen.main.bounds.height |
import SwiftUI
import EasySideMenu
struct SwiftUIRootView: View {
@State private var showMenu: Bool = false
var body: some View {
EasyMenuView(
style: .classic,
animation: .snappy(duration: 0.25, extraBounce: 0.1),
sideMenuWidth: UIScreen.main.bounds.width * 0.5,
cornerRadius: 25,
overlayColorWhenOpenMenu: Color.black.opacity(0.2),
dagToOpenMenu: (true, 10),
showMenu: $showMenu) { safeArea in
MainView(showMenu: $showMenu)
} menu: { safeArea in
MenuView(safeArea: safeArea)
} background: {
Rectangle()
.fill(Color.black.opacity(0.8))
}
}
}
#Preview {
SwiftUIRootView()
}
我们始终欢迎社区的贡献。要更改项目,您可以克隆仓库并打开 Package.swift
。此包包含
- Sources/EasySideMenu/EasyMenuEntity.swift
- Sources/EasySideMenu/EasyMenuView.swift
请全面测试所有更改,并按照模板创建一个 MR,我们将尽快评审。
tienvv88, [email protected]
EasySideMenu 可在 MIT 许可下获得。有关更多信息,请参阅 LICENSE 文件。