mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
This is a complete overhaul of the App Bar documentation, fully reflecting the most modern set of APIs that we encourage and expect clients to adopt. As part of this work, I've also written up the documentation for the various behavioral flags. Preview the App Bar docs:007a738fa5/components/AppBar/README.mdPreview the Flexible Header docs:007a738fa5/components/FlexibleHeader/README.mdCloses https://github.com/material-components/material-components-ios/issues/4653
1.8 KiB
1.8 KiB
Typical use: View controller containment, as a navigation controller
The easiest integration path for using the app bar is through the MDCAppBarNavigationController.
This API is a subclass of UINavigationController that automatically adds an
MDCAppBarViewController instance to each view controller that is pushed onto it, unless an app bar
or flexible header already exists.
When using the MDCAppBarNavigationController you will, at a minimum, need to configure the added
app bar's background color using the delegate.
Example
Swift
let navigationController = MDCAppBarNavigationController()
navigationController.pushViewController(<#T##viewController: UIViewController##UIViewController#>, animated: <#T##Bool#>)
// MARK: MDCAppBarNavigationControllerDelegate
func appBarNavigationController(_ navigationController: MDCAppBarNavigationController,
willAdd appBarViewController: MDCAppBarViewController,
asChildOf viewController: UIViewController) {
appBarViewController.headerView.backgroundColor = <#(UIColor)#>
}
Objective-C
MDCAppBarNavigationController *navigationController =
[[MDCAppBarNavigationController alloc] init];
[navigationController pushViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>];
#pragma mark - MDCAppBarNavigationControllerDelegate
- (void)appBarNavigationController:(MDCAppBarNavigationController *)navigationController
willAddAppBarViewController:(MDCAppBarViewController *)appBarViewController
asChildOfViewController:(UIViewController *)viewController {
appBarViewController.headerView.backgroundColor = <#(nonnull UIColor *)#>;
}