MDCFeatureHighlightViewController

@interface MDCFeatureHighlightViewController : UIViewController

MDCFeatureHighlightViewController highlights an element of a UI to introduce features or functionality that a user hasn’t tried.

https://material.io/guidelines/growth-communications/feature-discovery.html

MDCFeatureHighlightViewController should be presented modally and dismissed using either |acceptFeature| or |rejectFeature|.

While MDCFeatureHighlightViewController supports changing state while presented, it is not recommended as the design spec does not specify any patterns for that behavior.

Note

Due to a bug in the iOS simulator it is possible that the feature highlight will not render correctly in the simulator. If you’re encountering issues make sure to test on device.
  • Initializes the controller.

    Declaration

    Objective-C

    - (nonnull instancetype)
    initWithHighlightedView:(nonnull UIView *)highlightedView
                andShowView:(nonnull UIView *)displayedView
                 completion:(nullable MDCFeatureHighlightCompletion)completion;

    Parameters

    highlightedView

    The highlight will be presented above the |center| of |highlightedView|

    displayedView

    Added to the highlight view and centered at the |center| of |highlightedView|

    completion

    The completion block called when the highlight is dismissed

  • Initializes the controller.

    This is a convience method for |initWithHighlightedView:andShowView:| with a snapshot of |highlightedView| sent as |displayedView|.

    Declaration

    Objective-C

    - (nonnull instancetype)
    initWithHighlightedView:(nonnull UIView *)highlightedView
                 completion:(nullable MDCFeatureHighlightCompletion)completion;

    Parameters

    highlightedView

    The highlight will be presented above the |center| of |highlightedView|

  • Feature Highlight controllers must be created with either initWithHighlightedView: constructor.

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    - (nonnull instancetype)init NS_UNAVAILABLE;
  • Sets the text to be displayed as the header of the help text.

    The header is displayed above the body text.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *titleText;
  • Sets the text to be displayed as the body of the help text.

    The body is displayed below the header text. If you are only showing a single block of text without any header/body distinction, prefer |titleText|.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *bodyText;
  • Sets the color to be used for the outer highlight. Defaults to blue with an alpha of kMDCFeatureHighlightOuterHighlightAlpha.

    Alpha should be set to kMDCFeatureHighlightOuterHighlightAlpha.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *outerHighlightColor;
  • Sets the color to be used for the inner highlight. Defaults to white.

    Should be opaque.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *innerHighlightColor;
  • Sets the color to be used for the title text. If nil upon presentation, a color of sufficient contrast to the |outerHighlightColor| will be automatically chosen.

    Defaults to nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *titleColor;
  • Sets the color to be used for the body text. If nil upon presentation, a color of sufficient contrast to the |outerHighlightColor| will be automatically chosen upon presentation.

    Defaults to nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *bodyColor;
  • Sets the custom font to be used for the title text.

    Defaults to nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIFont *titleFont;
  • Sets the custom font to be used for the body text.

    Defaults to nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIFont *bodyFont;
  • Indicates whether the feature highlight contents should automatically update their font when the device’s UIContentSizeCategory changes.

    This property is modeled after the adjustsFontForContentSizeCategory property in the UIContentSizeCategoryAdjusting protocol added by Apple in iOS 10.0.

    Default value is NO.

    Declaration

    Objective-C

    @property (setter=mdc_setAdjustsFontForContentSizeCategory:, assign, readwrite,
              nonatomic) BOOL mdc_adjustsFontForContentSizeCategory;
  • Enable legacy font scaling curves for Dynamic Type. Default value is NO.

    Declaration

    Objective-C

    @property (setter=mdc_setLegacyFontScaling:, assign, readwrite, nonatomic)
        BOOL mdc_legacyFontScaling;
  • Dismisses the feature highlight using the ‘accept’ style dismissal animation and triggers the completion block with accepted set to YES.

    Identical to the user tapping on the inner highlight.

    Declaration

    Objective-C

    - (void)acceptFeature;
  • Dismisses the feature highlight using the ‘reject’ style dismissal animation and triggers the completion block with accepted set to NO.

    Identical to the user tapping outside of the inner highlight.

    Declaration

    Objective-C

    - (void)rejectFeature;