Coder Social home page Coder Social logo

boamenu's Introduction

BoaMenu

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.

Install

  1. Download BoaMenu.swift from this repository.
  2. Add it to your project.

Usage

With BoaMenu you have 2 options, you can:

  1. Use an already built BoaMenuTemplate.
  2. Create a new template using BoaMenuTemplate.

DefaultMenu (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).

alt text

StepMenu (BoaMenuTemplate)

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")!)

alt text

Create a new BoaMenuTemplate

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)

alt text

Create multiple menus

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.

alt text

Animations

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.

alt text

Quick Documentation

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

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.