The Wayback Machine - https://web.archive.org/web/20201211095741/https://github.com/stellz/MenuBarExampleSwift
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

README.md

MenuBarExampleSwift

Example Swift project implementing navigation menu bar. The project shows off a menu containing two options (Fruits & Vegetables) switching different data displayed in a table view. The project doesn't use storyboards. There are two view controllers - list view controller and an item view controller, created programmatically in code. For this simple project the MVC design pattern is used. When creating the item view controller instance, the model is being injected as a dependency in the designated initializer to follow best practices and for future testability of the class.

UI Control

Menu Bar

  • Example Usage:
// MARK: - Menu bar initialisation

// Create menu object and give it a frame
let menu = MenuBar(frame: CGRect(x: 0, y: 0, width: self.view.bounds.size.width - 2*15, height: navigationController?.navigationBar.intrinsicContentSize.height ?? 0)) 
// Put as many items as you want to have in you menu bar
menu.items = ["Item 1", "Item 2", "Item 3"] 
// Don't forget to set the delegate
menu.delegate = self 
// Add the menu to the navigation bar
navigationItem.titleView = menu 

// MARK: - Menu bar delegate

func menuBar(_ menuBar: MenuBar, didSelect index: Int) {
    print("Selected menu item: \(index)")
}

Example project in Objective C

MenuBarExampleObjectiveC

Build tools

  • Xcode 10.3
  • Swift 5
  • iOS 12.4

About

Example Swift project implementing navigation menu bar with sliding selector

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.