MDCInkView

@interface MDCInkView : UIView

A UIView that draws and animates the Material Design ink effect for touch interactions.

There are two kinds of ink:

Bounded ink: Ink that spreads from a point and is contained in the bounds of a UI element such as a button. The ink is visually clipped to the bounds of the UI element. Bounded ink is the most commonly-used ink in the system. Examples include basic Material buttons, list menu items, and tile grids.

Unbounded ink: Ink that spreads out from a point on top of other UI elements. It typically reaches a maximum circle radius and then fades, unclipped by other UI elements. Typically used when interacting with small UI elements such as navigation bar icons or slider thumb controls. Examples include overflow menus, icon toggle buttons, and phone dialer keys.

Note that the two kinds of ink are designed to have different animation parameters, that is, bounded ink isn’t just clipped unbounded ink. Whether the ink is bounded or not depends on the kind of UI element the user is interacting with.

  • Ink view animation delegate. Clients set this delegate to receive updates when ink animations start and end.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<MDCInkViewDelegate>
        animationDelegate;
  • The style of ink for this view. Defaults to MDCInkStyleBounded.

    Changes only affect subsequent animations, not animations in progress.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCInkStyle inkStyle;
  • The foreground color of the ink. The default value is defaultInkColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nonnull) UIColor *inkColor;
  • Default color used for ink if no color is specified.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UIColor *defaultInkColor;
  • Maximum radius of the ink. If the radius <= 0 then half the length of the diagonal of self.bounds is used. This value is ignored if @c inkStyle is set to |MDCInkStyleBounded|.

    Ignored if updated ink is used.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat maxRippleRadius;
  • Use the older legacy version of the ink ripple. Default is YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL usesLegacyInkRipple;
  • Use a custom center for the ink splash. If YES, then customInkCenter is used, otherwise the center of self.bounds is used. Default is NO.

    Affects behavior only if usesLegacyInkRipple is enabled.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL usesCustomInkCenter;
  • Custom center for the ink splash in the view’s coordinate system.

    Affects behavior only if both usesCustomInkCenter and usesLegacyInkRipple are enabled.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGPoint customInkCenter;
  • Start the first part of the press and release animation at a particular point.

    The press and release animation begins by fading in the ink ripple when this method is called.

    Declaration

    Objective-C

    - (void)startTouchBeganAnimationAtPoint:(CGPoint)point
                                 completion:(nullable MDCInkCompletionBlock)
                                                completionBlock;

    Parameters

    point

    The user interaction position in the view’s coordinate system.

    completionBlock

    Block called after the completion of the animation.

  • Start the second part of the press and release animation at a particular point.

    The press and release animation ends by completing the ink ripple expansion while fading out when this method is called.

    Declaration

    Objective-C

    - (void)startTouchEndedAnimationAtPoint:(CGPoint)point
                                 completion:(nullable MDCInkCompletionBlock)
                                                completionBlock;

    Parameters

    point

    The user interaction position in the view’s coordinate system.

    completionBlock

    Block called after the completion of the animation.

  • Cancel all animations.

    Declaration

    Objective-C

    - (void)cancelAllAnimationsAnimated:(BOOL)animated;

    Parameters

    animated

    If false, remove the animations immediately.

  • Start the first part of spreading the ink at a particular point.

    This begins by fading in the ink ripple when this method is called.

    Declaration

    Objective-C

    - (void)startTouchBeganAtPoint:(CGPoint)point
                          animated:(BOOL)animated
                    withCompletion:(nullable MDCInkCompletionBlock)completionBlock;

    Parameters

    point

    The user interaction position in the view’s coordinate system.

    animated

    to add the ink sublayer with animation or not.

    completionBlock

    Block called after the completion of the animation.

  • Start the second part of evaporating the ink at a particular point.

    This ends by completing the ink ripple expansion while fading out when this method is called.

    Declaration

    Objective-C

    - (void)startTouchEndAtPoint:(CGPoint)point
                        animated:(BOOL)animated
                  withCompletion:(nullable MDCInkCompletionBlock)completionBlock;

    Parameters

    point

    The user interaction position in the view’s coordinate system.

    animated

    to remove the ink sublayer with animation or not.

    completionBlock

    Block called after the completion of the animation.

  • Enumerates the given view’s subviews for an instance of MDCInkView and returns it if found, or creates and adds a new instance of MDCInkView if not.

    This method is a convenience method for adding ink to an arbitrary view without needing to subclass the target view. Use this method in situations where you expect there to be many distinct ink views in existence for a single ink touch controller. Example scenarios include:

    • Adding ink to individual collection view/table view cells

    This method can be used in your MDCInkTouchController delegate’s -inkTouchController:inkViewAtTouchLocation; implementation.

    Declaration

    Objective-C

    + (nonnull MDCInkView *)injectedInkViewForView:(nonnull UIView *)view;