SUISideMenu 0.5.0

SUISideMenu 0.5.0

Moaz Ezz维护。



  • moazezz

SUISideMenu

License Platform

如果您喜欢SUISideMenu,在本页右上角给他们一个★。

概述

SUISideMenu是为寻求简单而优雅解决方案的人提供的简单侧边菜单解决方案。它是用/为SwiftUI编写的。

  • 可调节菜单宽度、模糊、缩放和背景昏暗。
  • 两种菜单样式:slideInOver和slideInOut
  • 无需编写大量自定义代码即可全面自定义。
  • 处理屏幕旋转。
  • 使用SwiftUI编写的。

查看示例项目以了解其操作!

预览示例

slideInOver slideInOut

需求

  • Xcode 11 或更高版本。
  • Swift 5 或更高版本。
  • iOS 13 或更高版本。

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要使用 CocoaPods 将 SideMenu 集成到 Xcode 项目中,请在您的 Podfile 中指定它

pod 'SUISideMenu'

然后,运行以下命令

$ pod install

使用

代码实现

首先

import SUISideMenu

请确保按照以下示例在 SceneDelegte 中或作为以下示例中首选的环境Object 添加以下内容

.environmentObject(UIStateModel())

然后在第一个视图的主体中使用它如下

var body: some View {
        SideMenu(sideMenu: {
            //HERE:- Put The View you want to use as SideMenu
            //Example:
            Text("SideMenu")
                .frame(maxWidth: .infinity, maxHeight: .infinity)
                .background(Color.red)
        }, mainView: {
            //HERE:- Put The View you want to use as Main View
            //Example:
            Text("mainView")
                .frame(maxWidth: .infinity, maxHeight: .infinity)
                .background(Color.blue)
        }).environmentObject(UIStateModel()) //Very Important
    }

您可以根据以下方式自定义侧菜单

            SideMenu(menuWidth: 0.6, // <= 1
                     menuStyle: .slideInOver,// .slideInOver || .slideInOut
                     blur: 2,
                     scale: 1, // <= 1
                     dimValue: 0.2, // <= 1
                     sideMenu: {
                        //HERE:- Put The View you want to use as SideMenu
                        //Example:
                        Text("SideMenu")
                            .frame(maxWidth: .infinity, maxHeight: .infinity)
                            .background(Color.red)
            }, mainView: {
                //HERE:- Put The View you want to use as SideMenu
                //Example:
                Text("mainView")
                    .frame(maxWidth: .infinity, maxHeight: .infinity)
                    .background(Color.blue)
            }).environmentObject(UIStateModel()) //Very Important

致谢

受这篇文章的启发

https://medium.com/flawless-app-stories/implementing-snap-carousel-in-swiftui-3ae084504670

作者

Moazezz, [邮箱地址隐藏]

许可

SUISideMenu 遵循 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。