MDCDialogPresentationController

@interface MDCDialogPresentationController : UIPresentationController

MDCDialogPresentationController will present a modal ViewController as a dialog according to the Material spec.

https://material.io/go/design-dialogs

MDCDialogPresentationController should not be used to present full-screen dialogs.

The presented UIViewController will be asked for it’s preferredContentSize to help determine the best size for the dialog to be displayed.

This controller will manage the background dimming view and add a material-styled shadow underneath the presented view.

This controller will respond to the display / dismissal of the keyboard and update the presentedView’s frame.

  • An object conforming to MDCDialogPresentationControllerDelegate. When non-nil, the MDCDialogPresentationController will call the appropriate MDCDialogPresentationControllerDelegate methods on this object.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable)
        id<MDCDialogPresentationControllerDelegate>
            dialogPresentationControllerDelegate;
  • Should a tap on the dimmed background view dismiss the presented controller.

    Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL dismissOnBackgroundTap;
  • Customize the corner radius of the shadow to match the presented view’s corner radius.

    By default, the corner radius of the presented shadow is adjusted to match the corner radius of the view being presented. This behavior is achieved without making any changes to dialogCornerRadius. Once a value is set on dialogCornerRadius, that value will be used to determine the radius of both the presetned view and the shadow. That means that any further changes to the presented view’s corner radius (yourViewController.view.layer.cornerRadius) will be ignored once dialogCornerRadius is set.

    In either cases, the presentation controller ensures that the shadow layer’s corner radius matches the presented view’s.

    Material themers use dialogCornerRadius for setting the corner radius, therefore, when applying a themer to your custom UIViewController, any value you assign to your view’s corner radius will be ignored. If you wish to override the corner radius after a themer is called, make sure to set it to dialogCornerRadius, and not to the presented view’s corner radius.

    Defaults to: The presented view’s corner radius.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat dialogCornerRadius;
  • Customize the elevation of the shadow to match the presented view’s shadow.

    Defaults to 24.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCShadowElevation dialogElevation;
  • Customize the color of the background scrim.

    Defaults to a semi-transparent Black.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *scrimColor;
  • Returns the size of the specified child view controller’s content.

    The size is initially based on container.preferredSize. Width is will have a minimum of 280 and a maximum of the parentSize - 40 for the padding on the left and right size.

    Height has no minimum. Height has a maximum of the parentSize - height of any displayed keyboards - 48 for the padding on the top and bottom. If preferredSize.height is 0, height will be set to the maximum.

    Declaration

    Objective-C

    - (CGSize)sizeForChildContentContainer:(nonnull id<UIContentContainer>)container
                   withParentContainerSize:(CGSize)parentSize;
  • Returns the frame rectangle to assign to the presented view at the end of the animations.

    The size of the frame is determined by sizeForChildContentContainer:withParentContainerSize:. The presentedView is centered horizontally and verically in the available space. The available space is the size of the containerView subtracting any space taken up by the keyboard.

    Declaration

    Objective-C

    - (CGRect)frameOfPresentedViewInContainerView;