In order to react to flexible header frame changes you can set yourself as the MDCFlexibleHeaderViewController instance's layoutDelegate.
extension MyViewController: MDCFlexibleHeaderViewLayoutDelegate { // MARK: MDCFlexibleHeaderViewLayoutDelegate func flexibleHeaderViewController(_: MDCFlexibleHeaderViewController, flexibleHeaderViewFrameDidChange flexibleHeaderView: MDCFlexibleHeaderView) { // Called whenever the frame changes. } }
// Conform to MDCFlexibleHeaderViewLayoutDelegate @interface MyViewController () <MDCFlexibleHeaderViewLayoutDelegate> @end // Set yourself as the delegate. headerViewController.layoutDelegate = self; #pragma - MDCFlexibleHeaderViewLayoutDelegate - (void)flexibleHeaderViewController:(MDCFlexibleHeaderViewController *)flexibleHeaderViewController flexibleHeaderViewFrameDidChange:(MDCFlexibleHeaderView *)flexibleHeaderView { // Called whenever the frame changes. }
When pairing MDCFlexibleHeaderViewController with a view controller, it may be desirable to use the paired view controller‘s topLayoutGuide to constrain additionals views. To constrain the topLayoutGuide to the bottom point of the MDCFlexibleHeaderViewController, call updateTopLayoutGuide on the flexible header view controller within the paired view controller’s viewWillLayoutSubviews method.
override func viewWillLayoutSubviews() { super.viewDidLayoutSubviews() headerViewController.updateTopLayoutGuide() }
- (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; [self.headerViewController updateLayoutGuide]; }