MDCAppBarContainerViewController

@interface MDCAppBarContainerViewController : UIViewController

The MDCAppBarContainerViewController controller provides an interface for placing a UIViewController behind an App Bar.

The MDCAppBarContainerViewController class is commonly referred to as the wrapper API for the Material App Bar. This contrasts with the injection APIs as represented by the APIs in MDCAppBar.h.

Use the MDCAppBarContainerViewController class when you do not own and cannot alter a view controller to which you want to add an App Bar. If you do own and can modify a view controller it is recommended that you use the MDCAppBar.h APIs instead.

Why we recommend using the MDCAppBar.h APIs over this one

Wrapping a view controller affects your app code in a variety of not-so-nice ways.

  1. Wrapped view controllers often need to be unwrapped in a variety of settings.
  2. The wrapped view controller’s parentViewController is now a level of indirection from its previous parent.
  3. Wrapping a view controller can affect things like isMovingToParentViewController in wonderfully subtle ways.
  • Initializes an App Bar container view controller instance with the given content view controller.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithContentViewController:
        (nonnull UIViewController *)contentViewController;
  • Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
                                     bundle:(nullable NSBundle *)nibBundleOrNil NS_UNAVAILABLE;
  • Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCoder:(nonnull NSCoder *)aDecoder NS_UNAVAILABLE;
  • Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)init NS_UNAVAILABLE;
  • The App Bar view controller that will be a sibling to the contentViewController.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull)
        MDCAppBarViewController *appBarViewController;
  • The content view controller to be displayed behind the header.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull)
        UIViewController *contentViewController;
  • If enabled, the content view controller’s top layout guide will be adjusted as the flexible header’s height changes and the content view controller view’s frame will be set to the container view controller’s bounds.

    This behavior is disabled by default, but it will be enabled by default in the future. Consider enabling this behavior and making use of the topLayoutGuide in your view controller accordingly.

    Example positioning a view using constraints:

    [NSLayoutConstraint constraintWithItem:view
                                 attribute:NSLayoutAttributeTop
                                 relatedBy:NSLayoutRelationEqual
                                    toItem:self.topLayoutGuide
                                 attribute:NSLayoutAttributeBottom
                                multiplier:1
                                  constant:32]
    

    Example positioning a view without constraints:

    frame.origin.y = self.topLayoutGuide.length + 32
    

    Declaration

    Objective-C

    @property (getter=isTopLayoutGuideAdjustmentEnabled, assign, readwrite,
              nonatomic) BOOL topLayoutGuideAdjustmentEnabled;