How to use and access App Bar Bottom(Material Design) in swift?

200 views Asked by At

I am trying to use the App Bar: Bottom from Material Design in my ios project. Added the MDCBottomAppBarView() class as UIView like this:
enter image description here

But the bottom bar is showing in the top like this:
enter image description here

Can someone tell me how to access the MDCBottomAppBarView() class and customize. And also show the bar at bottom of the app.

1

There are 1 answers

0
Memduh Çatalkaya On

This is how i used MDCBottomAppBarView().

First create a bottom app bar and a floating button to access the floating button which MDCBottomAppBarView() have as default.

let bottomAppBar = MDCBottomAppBarView()
var floatingButton = MDCFloatingButton()

Then you can configure your app bar and button,

override func viewDidLoad() {
    super.viewDidLoad()
    floatingButton = bottomAppBar.floatingButton
    // configure floating button and app bar
    floatingButton.setImage(UIImage(systemName: "plus"), for: UIControl.State.normal)
    floatingButton.tintColor = .white
    floatingButton.backgroundColor = UIColor(named: "customColor")
    bottomAppBar.barTintColor = UIColor(named: "customColor")
    // and important thing is you have to configure a frame for app bar
    bottomAppBar.frame = CGRect(x: 0, y: view.frame.height * 0.86, width: view.frame.width, height: view.frame.height * 0.14)
    // add the app bar in your view
    view.addSubview(bottomAppBar)
}