Create a floating menu in an iOS application

Want to create a floating menu in Swift for the iOS app I'm developing. Something along the lines of the small menu of red circles, as shown in the following image.

enter image description here

My initial thoughts were to extend the UIViewController class and add the corresponding drawing / logic there, however the application consists of several other controllers, more specifically the UITableViewController, which itself extends the UIViewController. Is there perhaps a good place to expand? Or is there a more eloquent way of drawing menus on certain views without mass duplication of code associated with the menu?

The menu itself will be displayed on most screens, so I need to selectively enable it. It will also be somewhat contextual based on the view / screen in which the user is currently logged on.

Any amazing ideas?

+2
source share
3 answers

You can create your own with animation and all things, or you can check out this library.

https://github.com/lourenco-marinho/ActionButton

var actionButton: ActionButton! override func viewDidLoad() { super.viewDidLoad() let twitterImage = UIImage(named: "twitter_icon.png")! let plusImage = UIImage(named: "googleplus_icon.png")! let twitter = ActionButtonItem(title: "Twitter", image: twitterImage) twitter.action = { item in println("Twitter...") } let google = ActionButtonItem(title: "Google Plus", image: plusImage) google.action = { item in println("Google Plus...") } actionButton = ActionButton(attachedToView: self.view, items: [twitter, google]) actionButton.action = { button in button.toggleMenu() } } 

enter image description here

+4
source

You can use view controller protection. A menu can be its own view controller; its view is transparently located above the content view controller.

For example, this can be configured in the storyboard by dragging two kinds of container into the vanilla view controller.

+1
source

There is another alternative in this large library:

https://github.com/yoavlt/LiquidFloatingActionButton

You just need to implement the delegate and data source in your ViewController:

 let floatingActionButton = LiquidFloatingActionButton(frame: floatingFrame) floatingActionButton.dataSource = self floatingActionButton.delegate = self 

enter image description here

+1
source

All Articles