Lightweight and easy to use Menu written in Swift 4.
The main goal of BoaMenu is to offer a simple yet powerful Menu that requires almost no setup and is very easy to use. This is not a complex Menu and does not include a lot of characteristics that other third-parties Menus have already built.
BoaMenu is great when it comes to simplicity and due to it's generic methods it may be used it as a checkpoint of your own Menu; that means that you can build your very own Menu using BoaMenu as a foundation.
So far, BoaMenu supports horizontal menus only.
- Download BoaMenu.swift from this repository.
- Add it to your project.
With BoaMenu you have 2 options, you can:
- Use an already built BoaMenuTemplate.
- Create a new template using BoaMenuTemplate.
var menu = BoaMenu.DefaultMenu(target: self)
The code above will create a white BoaMenu with 5 spaces at the bottom of the view. You can see an example of the DefaultMenu below (consider that we have not shown how to add images nor events to the buttons).
Another useful BoaMenuTemplate (and my personal favorite) is StepMenu
This template builds a white BoaMenu with 5 spaces at the bottom of the view. The first and last space of the menu will be used to show two buttons
(back and next step).
var menu = BoaMenu.StepMenu(target: self, backImage: UIImage(named:"back-image-name")!, nextImage: UIImage(named:"next-image-name")!)
BoaMenuTemplate is basically a struct that will allow you to build a customizable BoaMenu.
The init function of BoaMenuTemplate requests at least 3 parameters.
init(frame:CGRect, backgroundColor:UIColor, numberOfButtons:Int)
The frame:CGRect
parameter is just the frame of the BoaMenu.
Use backgroundColor:UIColor
to change the background color of the BoaMenu.
With numberOfButtons:Int
you tell BoaMenuTemplate how many spaces the BoaMenu should have.
Here is an example of using a custom BoaMenuTemplate to create a BoaMenu.
let frame = CGRect(x: (view.frame.size.width/4), y: view.frame.height-80, width: view.frame.size.width/2, height: 80)
let template = BoaMenuTemplate(frame: frame, backgroundColor: .black, numberOfButtons: 2)
let menu = BoaMenu.WithTemplate(template: template, target: self)
Since BoaMenu is lightweight, there is no problem with adding multiple menus to your view. Just remember to be original and you will find amazing approaches when using it.
Remember that BoaMenu is a simple UIView with UIButton(s) inside, so feel free to perform your favorite animation without worrying about the performance of your app.
Add an image to a specific button.
func setIcon(index i:Int, image:UIImage?)
Add all the images of all the buttons (from left to right)
func setIcons(_ imagesNames:[String])
Add a touchUpInside event to a button
func setAction(to b:UIButton, selector:Selector)
Attach a different UIControlEvent to a button
func setAction(to b:UIButton, selector:Selector, event:UIControlEvents){
Find the rest of the functions in BoaMenu.swift file