MDCCardCollectionCell

@interface MDCCardCollectionCell : UICollectionViewCell

/**
 When selectable is set to YES, a tap on a cell will trigger a visual change between selected
 and unselected. When it is set to NO, a tap will trigger a normal tap (rather than trigger
 different visual selection states on the card).
 Default is set to NO.
 */
@property(nonatomic, assign, getter=isSelectable) BOOL selectable;

/**
 A Boolean value indicating whether the card is in the dragged state.
 */
@property(nonatomic, getter=isDragged) BOOL dragged;

/**
 The corner radius for the card
 Default is set to 4.
 */
@property(nonatomic, assign) CGFloat cornerRadius UI_APPEARANCE_SELECTOR;

/**
 The inkView for the card that is initiated on tap
 */
@property(nonatomic, readonly, strong, nonnull) MDCInkView *inkView;

/**
 The rippleView for the card that is initiated on tap. The ripple view is the successor of ink
 view, and can be used by setting `enableRippleBehavior` to YES after initializing the card.
 */
@property(nonatomic, readonly, strong, nonnull) MDCStatefulRippleView *rippleView;

/**
 This property defines if a card as a whole should be interactable or not.
 What this means is that when isInteractable is set to NO, there will be no ink ripple and
 no change in shadow elevation when tapped or selected. Also the card container itself will not be
 tappable, but any of its subviews will still be tappable.

 Default is set to YES.

 Important: Our specification for cards explicitly define a card as being an interactable component.
 Therefore, this property should be set to NO *only if* there are other interactable items within
 the card's content, such as buttons or other tappable controls.
 */
@property(nonatomic, getter=isInteractable) IBInspectable BOOL interactable;

/*
 The shape generator used to define the card cell's shape.
 When set, layer properties such as cornerRadius and other layer properties are nullified/zeroed.
 If a layer property is explicitly set after the shapeGenerator has been set, it will lead to
 unexpected behavior.

 When the shapeGenerator is nil, MDCCardCollectionCell will use the default underlying layer with
 its default settings.

 Default value for shapeGenerator is nil.
 */
@property(nullable, nonatomic, strong) id<MDCShapeGenerating> shapeGenerator;

/**
 By setting this property to YES, you will enable and use inkView's successor rippleView as the
 main view to provide visual feedback for taps. It is recommended to set this property right after
 initializing the card.

 Defaults to NO.
 */
@property(nonatomic, assign) BOOL enableRippleBehavior;

/**
 Sets the shadow elevation for an MDCCardViewState state

 @param shadowElevation The shadow elevation
 @param state MDCCardCellState the card state
 */
- (void)setShadowElevation:(MDCShadowElevation)shadowElevation
                  forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the shadow elevation for an MDCCardViewState state

 If no elevation has been set for a state, the value for MDCCardCellStateNormal will be returned.
 Default value for MDCCardCellStateNormal is 1
 Default value for MDCCardCellStateHighlighted is 8
 Default value for MDCCardCellStateSelected is 8

 @param state MDCCardCellStateNormal the card state
 @return The shadow elevation for the requested state.
 */
- (MDCShadowElevation)shadowElevationForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Sets the border width for an MDCCardViewState state

 @param borderWidth The border width
 @param state MDCCardCellState the card state
 */
- (void)setBorderWidth:(CGFloat)borderWidth forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the border width for an MDCCardCellState state

 If no border width has been set for a state, the value for MDCCardCellStateNormal will be returned.
 Default value for MDCCardCellStateNormal is 0

 @param state MDCCardCellState the card state
 @return The border width for the requested state.
 */
- (CGFloat)borderWidthForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Sets the border color for an MDCCardCellStateNormal state

 @param borderColor The border color
 @param state MDCCardCellState the card state
 */
- (void)setBorderColor:(nullable UIColor *)borderColor
              forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the border color for an MDCCardCellStateNormal state

 If no border color has been set for a state, it will check the value of UIControlStateNormal.
 If that value also isn't set, then nil will be returned.

 @param state MDCCardCellState the card state
 @return The border color for the requested state.
 */
- (nullable UIColor *)borderColorForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Sets the shadow color for an MDCCardCellStateNormal state

 @param shadowColor The shadow color
 @param state MDCCardCellState the card state
 */
- (void)setShadowColor:(nullable UIColor *)shadowColor
              forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the shadow color for an MDCCardCellStateNormal state

 If no color has been set for a state, the value for MDCCardViewStateNormal will be returned.
 Default value for MDCCardCellStateNormal is blackColor

 @param state MDCCardCellState the card state
 @return The shadow color for the requested state.
 */
- (nullable UIColor *)shadowColorForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the image for an MDCCardCellStateNormal state.

 @note The image is only displayed when `selectable` is YES.
 If no image has been set for a state, it will check the value of UIControlStateNormal.
 If that value also isn't set, then nil will be returned.
 Default value for MDCCardCellStateSelected is ic_check_circle

 @param state MDCCardCellState the card state
 @return The image for the requested state.
 */
- (nullable UIImage *)imageForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Sets the image for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 @param image The image
 @param state MDCCardCellState the card state
 */
- (void)setImage:(nullable UIImage *)image forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the horizontal image alignment for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 If no alignment has been set for a state, it will check the value of UIControlStateNormal.
 If that value also isn't set, then MDCCardCellImageHorizontalAlignmentRight will be returned.

 @param state MDCCardCellState the card state
 @return The horizontal alignment for the requested state.
 */
- (MDCCardCellHorizontalImageAlignment)horizontalImageAlignmentForState:(MDCCardCellState)state
    UI_APPEARANCE_SELECTOR;

/**
 Sets the image alignment for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 @param horizontalImageAlignment The image alignment
 @param state MDCCardCellState the card state
 */
- (void)setHorizontalImageAlignment:(MDCCardCellHorizontalImageAlignment)horizontalImageAlignment
                           forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the vertical image alignment for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 If no alignment has been set for a state, it will check the value of UIControlStateNormal.
 If that value also isn't set, then MDCCardCellImageVerticalAlignmentTop will be returned.

 @param state MDCCardCellState the card state
 @return The vertical alignment for the requested state.
 */
- (MDCCardCellVerticalImageAlignment)verticalImageAlignmentForState:(MDCCardCellState)state
    UI_APPEARANCE_SELECTOR;

/**
 Sets the image alignment for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 @param verticalImageAlignment The image alignment
 @param state MDCCardCellState the card state
 */
- (void)setVerticalImageAlignment:(MDCCardCellVerticalImageAlignment)verticalImageAlignment
                         forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Returns the image tint color for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 If no tint color has been set for a state, it will check the value of UIControlStateNormal.
 If that value also isn't set, then nil will be returned.

 @param state MDCCardCellState the card state
 @return The image tint color for the requested state.
 */
- (nullable UIColor *)imageTintColorForState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 Sets the image tint color for an MDCCardCellStateNormal state

 @note The image is only displayed when `selectable` is YES.
 @param imageTintColor The image tint color
 @param state MDCCardCellState the card state
 */
- (void)setImageTintColor:(nullable UIColor *)imageTintColor
                 forState:(MDCCardCellState)state UI_APPEARANCE_SELECTOR;

/**
 The state of the card cell.
 Default is MDCCardCellStateNormal.
 */
@property(nonatomic, readonly) MDCCardCellState state;

@end

Undocumented

  • When selectable is set to YES, a tap on a cell will trigger a visual change between selected and unselected. When it is set to NO, a tap will trigger a normal tap (rather than trigger different visual selection states on the card). Default is set to NO.

    Declaration

    Objective-C

    @property (getter=isSelectable, assign, readwrite, nonatomic) BOOL selectable;
  • A Boolean value indicating whether the card is in the dragged state.

    Declaration

    Objective-C

    @property (getter=isDragged, assign, readwrite, nonatomic) BOOL dragged;
  • The corner radius for the card Default is set to 4.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat cornerRadius;
  • The inkView for the card that is initiated on tap

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) MDCInkView *inkView;
  • The rippleView for the card that is initiated on tap. The ripple view is the successor of ink view, and can be used by setting enableRippleBehavior to YES after initializing the card.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull)
        MDCStatefulRippleView *rippleView;
  • This property defines if a card as a whole should be interactable or not. What this means is that when isInteractable is set to NO, there will be no ink ripple and no change in shadow elevation when tapped or selected. Also the card container itself will not be tappable, but any of its subviews will still be tappable.

    Default is set to YES.

    Important: Our specification for cards explicitly define a card as being an interactable component. Therefore, this property should be set to NO only if there are other interactable items within the card’s content, such as buttons or other tappable controls.

    Declaration

    Objective-C

    @property (getter=isInteractable, assign, readwrite, nonatomic)
        BOOL interactable;
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) id<MDCShapeGenerating> shapeGenerator
  • By setting this property to YES, you will enable and use inkView’s successor rippleView as the main view to provide visual feedback for taps. It is recommended to set this property right after initializing the card.

    Defaults to NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL enableRippleBehavior;
  • Sets the shadow elevation for an MDCCardViewState state

    Declaration

    Objective-C

    - (void)setShadowElevation:(MDCShadowElevation)shadowElevation
                      forState:(MDCCardCellState)state;

    Parameters

    shadowElevation

    The shadow elevation

    state

    MDCCardCellState the card state

  • Returns the shadow elevation for an MDCCardViewState state

    If no elevation has been set for a state, the value for MDCCardCellStateNormal will be returned. Default value for MDCCardCellStateNormal is 1 Default value for MDCCardCellStateHighlighted is 8 Default value for MDCCardCellStateSelected is 8

    Declaration

    Objective-C

    - (MDCShadowElevation)shadowElevationForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellStateNormal the card state

    Return Value

    The shadow elevation for the requested state.

  • Sets the border width for an MDCCardViewState state

    Declaration

    Objective-C

    - (void)setBorderWidth:(CGFloat)borderWidth forState:(MDCCardCellState)state;

    Parameters

    borderWidth

    The border width

    state

    MDCCardCellState the card state

  • Returns the border width for an MDCCardCellState state

    If no border width has been set for a state, the value for MDCCardCellStateNormal will be returned. Default value for MDCCardCellStateNormal is 0

    Declaration

    Objective-C

    - (CGFloat)borderWidthForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The border width for the requested state.

  • Sets the border color for an MDCCardCellStateNormal state

    Declaration

    Objective-C

    - (void)setBorderColor:(nullable UIColor *)borderColor
                  forState:(MDCCardCellState)state;

    Parameters

    borderColor

    The border color

    state

    MDCCardCellState the card state

  • Returns the border color for an MDCCardCellStateNormal state

    If no border color has been set for a state, it will check the value of UIControlStateNormal. If that value also isn’t set, then nil will be returned.

    Declaration

    Objective-C

    - (nullable UIColor *)borderColorForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The border color for the requested state.

  • Sets the shadow color for an MDCCardCellStateNormal state

    Declaration

    Objective-C

    - (void)setShadowColor:(nullable UIColor *)shadowColor
                  forState:(MDCCardCellState)state;

    Parameters

    shadowColor

    The shadow color

    state

    MDCCardCellState the card state

  • Returns the shadow color for an MDCCardCellStateNormal state

    If no color has been set for a state, the value for MDCCardViewStateNormal will be returned. Default value for MDCCardCellStateNormal is blackColor

    Declaration

    Objective-C

    - (nullable UIColor *)shadowColorForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The shadow color for the requested state.

  • Returns the image for an MDCCardCellStateNormal state.

    Note

    The image is only displayed when selectable is YES. If no image has been set for a state, it will check the value of UIControlStateNormal. If that value also isn’t set, then nil will be returned. Default value for MDCCardCellStateSelected is ic_check_circle

    Declaration

    Objective-C

    - (nullable UIImage *)imageForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The image for the requested state.

  • Sets the image for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES.

    Declaration

    Objective-C

    - (void)setImage:(nullable UIImage *)image forState:(MDCCardCellState)state;

    Parameters

    image

    The image

    state

    MDCCardCellState the card state

  • Returns the horizontal image alignment for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES. If no alignment has been set for a state, it will check the value of UIControlStateNormal. If that value also isn’t set, then MDCCardCellImageHorizontalAlignmentRight will be returned.

    Declaration

    Objective-C

    - (MDCCardCellHorizontalImageAlignment)horizontalImageAlignmentForState:
        (MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The horizontal alignment for the requested state.

  • Sets the image alignment for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES.

    Declaration

    Objective-C

    - (void)setHorizontalImageAlignment:
                (MDCCardCellHorizontalImageAlignment)horizontalImageAlignment
                               forState:(MDCCardCellState)state;

    Parameters

    horizontalImageAlignment

    The image alignment

    state

    MDCCardCellState the card state

  • Returns the vertical image alignment for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES. If no alignment has been set for a state, it will check the value of UIControlStateNormal. If that value also isn’t set, then MDCCardCellImageVerticalAlignmentTop will be returned.

    Declaration

    Objective-C

    - (MDCCardCellVerticalImageAlignment)verticalImageAlignmentForState:
        (MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The vertical alignment for the requested state.

  • Sets the image alignment for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES.

    Declaration

    Objective-C

    - (void)setVerticalImageAlignment:
                (MDCCardCellVerticalImageAlignment)verticalImageAlignment
                             forState:(MDCCardCellState)state;

    Parameters

    verticalImageAlignment

    The image alignment

    state

    MDCCardCellState the card state

  • Returns the image tint color for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES. If no tint color has been set for a state, it will check the value of UIControlStateNormal. If that value also isn’t set, then nil will be returned.

    Declaration

    Objective-C

    - (nullable UIColor *)imageTintColorForState:(MDCCardCellState)state;

    Parameters

    state

    MDCCardCellState the card state

    Return Value

    The image tint color for the requested state.

  • Sets the image tint color for an MDCCardCellStateNormal state

    Note

    The image is only displayed when selectable is YES.

    Declaration

    Objective-C

    - (void)setImageTintColor:(nullable UIColor *)imageTintColor
                     forState:(MDCCardCellState)state;

    Parameters

    imageTintColor

    The image tint color

    state

    MDCCardCellState the card state

  • The state of the card cell. Default is MDCCardCellStateNormal.

    Declaration

    Objective-C

    @property (readonly, nonatomic) MDCCardCellState state;