Adds back compatibility to UIMenu by replacing it with UIAlertController for iOS SDK versions prior to 14.0
(iOS SDK >=14.0 and <14.0 has different representation for the menu)
To play with usage example navigate to ListMenuExample folder and look at ListMenuExample.xcodeproj
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/syngenta/ListMenuSwift.git
In a place where you are going to implement the functionality you need to import the library:
import ListMenu
Add a menu variable and set up a list of menu items
private var menu: ListMenu?
private var menuItems: [ListMenuItem] {
[ListMenuItem(title: "Kyiv"),
ListMenuItem(title: "Kharkiv", image: UIImage(systemName: "atom")),
ListMenuItem(title: "Odesa", image: UIImage(systemName: "ferry.fill"), value: 1004)]
}
Set up the menu
override func viewDidLoad() {
super.viewDidLoad()
menu = ListMenu(presentButton: menuButton,
title: "Cities",
items: menuItems,
eventsHandler: self)
}
And handle selected items
extension YourController: ListMenuEvents {
func didSelect(item: ListMenuItem) {
print("Did select item - \(String(describing: item.value))")
}
}
Dmytro Romanov, dimkahr@gmail.com
MapLauncher is available under the MIT license. See the LICENSE file for more info.