EasySideMenu 0.1.9

EasySideMenu 0.1.9

Tienvv88 维护。



EasySideMenu

Group 13428

依赖

Swift 5.x, iOS 15+

安装

CocoaPods

EasySideMenu 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile:

pod 'EasySideMenu'

Swift Package Manager

  1. 文件 > Swift 包 > 添加包依赖
  2. 添加 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

参数

init EasySideMenu

参数 值类型 默认值
风格 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 强制

EasyMenuStyle

风格 参数 值范围
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

用法

SwiftUI

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 文件。