The Material Design top app bar displays information and actions relating to the current view.
The top app bar is implemented on iOS in the AppBar component. This component's main API is MDCAppBar, a compose API that initializes and provides access to instances of the following components:
The provided view hierarchy looks like so:
<MDCFlexibleHeaderView> | <CALayer> | | <MDCShadowLayer> | <UIView> <- headerView.contentView | | <MDCHeaderStackView> | | | <MDCNavigationBar>
This view hierarchy will be added to your view controller hierarchy using the convenience methods outlined in the Usage docs below.
Note that it is possible to create each of the above components yourself, though we only encourage doing so if the App Bar is limiting your ability to build something. In such a case we recommend also filing an issue so that we can identify whether your use case is something we can directly support.
The App Bar begins mirroring the state of your view controller's navigationItem in the provided navigationBar once you call addSubviewsToParent.
Learn more by reading the Navigation Bar section on Observing UINavigationItem instances. Notably: read the section on “Exceptions” to understand which UINavigationItem are not supported.
Scenario: you‘ve added a background image to your App Bar and you’d now like to be able to tap the background image.
This is not trivial to do with the App Bar APIs due to considerations being discussed in Issue #184.
The heart of the limitation is that we're using a view (headerStackView) to lay out the Navigation Bar. If you add a background view behind the headerStackView instance then headerStackView will end up eating all of your touch events.
Until Issue #184 is resolved, our recommendation for building interactive background views is the following:
See the FlexibleHeader documentation for additional usage guides.