FTPopOverMenu_Swift 0.4.5

FTPopOverMenu_Swift 0.4.5

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最新发布2023年11月
SPM支持 SPM

liufengting 维护。




  • liufengting

FTPopOverMenu

Twitter Carthage compatible GitHub license Version Download CocoaPods GitHub stars

Swift 版本的 FTPopOverMenu

FTPopOverMenu

FTPopOverMenu 是一个用于 iOS 的弹出菜单,可能是最容易使用的,支持 纵向横向。它可以从任何 UIView、任何 UIBarButtonItem 和任何 CGRect 显示。最简单的 API,让您只需一行代码即可改变样式。

有时我想为每个单元格定制,所以我将全局设置和单元格设置分开。例如:我的项目经理想要一些菜单项显示,但出于某种原因不能点击。

屏幕截图

screenshot

安装

手动安装

  • 克隆此仓库。
  • 简单地将 '/FTPopOverMenu_Swift/FTPopOverMenu.swift' 文件拖放到项目中。

CocoaPods

FTPopOverMenu_Swift 是通过 CocoaPods 可用的。要安装它,只需将以下行添加到您的 Podfile

  • 对于 Swift 4,请使用版本 <= 0.1.4
  • 对于 Swift 5,请使用版本 >= 0.2.0
  • 在 0.3.0 版本中进行了大规模 API 变更,更新时请自行承担风险。
  • 版本 >= 0.4.1 Version,框架名称已从 FTPopOverMenu_Swift 改为 FTPopOverMenu
target 'MyApp' do
    pod 'FTPopOverMenu_Swift', '~> 0.1.4'
end

然后,在终端运行 pod install 命令,或者在 CocoaPods.app 中运行。

使用方法

自定义

执行以下设置以设置样式(只设置您想要更改的设置),可能是在应用程序启动时或在您想要显示不同样式时进行,但要记住这是全局更改。

    let configuration = FTConfiguration.shared
    configuration.menuRowHeight = ...
    configuration.menuWidth = ...
    configuration.textColor = ...
    configuration.textFont = ...
    configuration.tintColor = ...
    configuration.borderColor = ...
    configuration.borderWidth = ...
    configuration.textAlignment = ...
    configuration.ignoreImageOriginalColor = ...;
    // set 'ignoreImageOriginalColor' to YES, images color will be same as textColor

从 SenderView,无图片菜单

        FTPopOverMenu.showForSender(sender: sender,
                                    with: ["Share"],
                                    done: { (selectedIndex) -> () in
                              
                                        print(selectedIndex)
        }) {
            
        }

从 SenderView,带图片菜单

        FTPopOverMenu.showForSender(sender: sender,
                                    with: ["Share"],
                                    menuImageArray: ["iconImageName"],
                                    done: { (selectedIndex) -> () in
                              
                                        print(selectedIndex)
        }) {
            
        }

从发送者框架/导航项,无图像菜单。

        FTPopOverMenu.showFromSenderFrame(senderFrame: sender.frame,
                                          with: ["Share"],
                                          done: { (selectedIndex) -> () in
                                            
        }) {
            
        }

从发送者框架/导航项,带图像菜单。

        FTPopOverMenu.showFromSenderFrame(senderFrame: sender.frame,
                                          with: ["Share"],
                                          menuImageArray: ["iconImageName"],
                                          done: { (selectedIndex) -> () in
                                            
        }) {
            
        }

从 barButtonItems.

  • 第一步:为 barButtonItems 添加事件动作
    @IBAction func handleAddBarButtonItem(_ sender: UIBarButtonItem, event: UIEvent) {
        
        FTPopOverMenu.showForEvent(event: event,
                                   with: ["Share"],
                                   menuImageArray: ["iconImageName"],
                                   done: { (selectedIndex) -> () in
        
        }) {
            
        }
    }

变更日志

更改日志

更多

  • Swift 版本的 FTPopOverMenu
  • 标志设计者是 @Tobaloidee
  • 演示中的图像来源于 https://www.iconfinder.com/iconsets/pokemon-go
  • 如果你喜欢它,或者想在你的项目中使用它,请给我一个 star
  • 在寻找另一种方法来做到这一点?看看我的另一个 FTPopMenu 在这里。这是一种弹出菜单的另一种展示方式,基于 UIPopoverViewController,更加通用和美观。欢迎试用。

许可协议

FTPopOverMenu_SwiftMIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。