MDCFloatingButton

@interface MDCFloatingButton : MDCButton

A floating MDCButton.

Floating action buttons are circular, float a considerable amount above their parent, have their own background color, and also raise briefly when touched. Floating action buttons should only be used rarely, for the main action of a screen.

  • The mode of the floating button can either be .normal (a circle) or .expanded (a pill-shaped rounded rectangle). In the @c .normal mode, the button should have either an image or a title, but not both. In the @c .expanded mode, the button should have both an image and a title.

    The @c .normal layout is identical to that of UIButton. The content will be centered (or otherwise aligned based on the @c contentHorizontalAlignment and @c contentVerticalAlignment properties. In @c .expanded layout, the image view will be inset from the leading edge (or trailing edge when @c imageLocation is .trailing). The bounding box for the title will be inset from the opposite edge and separated from @c imageView by @c imageTitleSpace and the title label will be leading-aligned within this box. In @c .expanded mode, the @c contentVerticalAlignment and @c contentHorizontalAlignment properties are ignored.

    The default value is @c .normal .

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCFloatingButtonMode mode;
  • The location of the image relative to the title when the floating button is in @c expanded mode.

    The default value is @c .leading .

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        MDCFloatingButtonImageLocation imageLocation;
  • The horizontal spacing in points between the @c imageView and @c titleLabel when the button is in @c .expanded mode. If set to a negative value, the image and title may overlap.

    The default value is 8.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat imageTitleSpace;
  • Returns a MDCFloatingButton with default colors and the given @c shape.

    Declaration

    Objective-C

    + (nonnull instancetype)floatingButtonWithShape:(MDCFloatingButtonShape)shape;

    Parameters

    shape

    Button shape.

    Return Value

    Button with shape.

  • Declaration

    Objective-C

    + (CGFloat)defaultDimension;

    Return Value

    The default floating button size dimension.

  • Declaration

    Objective-C

    + (CGFloat)miniDimension;

    Return Value

    The mini floating button size dimension.

  • Initializes self to a button with the given @c shape.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFrame:(CGRect)frame
                                    shape:(MDCFloatingButtonShape)shape;

    Parameters

    frame

    Button frame.

    shape

    Button shape.

    Return Value

    Button with shape.

  • Initializes self to a button with the MDCFloatingButtonShapeDefault shape.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFrame:(CGRect)frame;

    Parameters

    frame

    Button frame.

    Return Value

    Button with MDCFloatingButtonShapeDefault shape.

  • Initializes self to a button with the MDCFloatingButtonShapeDefault shape.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Return Value

    Button with MDCFloatingButtonShapeDefault shape.

  • Undocumented

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    - (void)setMinimumSize:(CGSize)size;
  • Sets the minimum size when the button has the specified @c shape @c mode. Setting a size of @c CGSizeZero is equivalent to no minimum size. To set a fixed size for a button, use the same value when setting the minimum and maximum sizes for a @c shape and @c mode combination.

    Declaration

    Objective-C

    - (void)setMinimumSize:(CGSize)minimumSize
                  forShape:(MDCFloatingButtonShape)shape
                    inMode:(MDCFloatingButtonMode)mode;

    Parameters

    minimumSize

    The new minimum size of the button.

    shape

    The shape that the size constrains.

    mode

    The mode that the size constrains.

  • Undocumented

    Declaration

    Objective-C

    - (void)setMaximumSize:(CGSize)maximumSize;
  • Sets the maximum size when the button has the specified @c shape and @c mode. Setting a size of @c CGSizeZero is equivalent to no maximum size. To set a fixed size for a button, use the same value when setting the minimum and maximum sizes for a @c shape and @c mode combination.

    Declaration

    Objective-C

    - (void)setMaximumSize:(CGSize)maximumSize
                  forShape:(MDCFloatingButtonShape)shape
                    inMode:(MDCFloatingButtonMode)mode;

    Parameters

    maximumSize

    The new maximum size of the button.

    shape

    The shape that the size constrains.

    mode

    The mode that the size constrains.

  • Undocumented

    Declaration

    Objective-C

    - (void)setContentEdgeInsets:(UIEdgeInsets)contentEdgeInsets NS_UNAVAILABLE;
  • Sets the @c contentEdgeInsets value when the button has the specified @c shape and @c mode. The behavior of @c contentEdgeInsets is the same as for UIButton. The button will layout its subviews within the rectangle generated by insetting its @c bounds by @c contentEdgeInsets.

    Declaration

    Objective-C

    - (void)setContentEdgeInsets:(UIEdgeInsets)contentEdgeInsets
                        forShape:(MDCFloatingButtonShape)shape
                          inMode:(MDCFloatingButtonMode)mode;

    Parameters

    contentEdgeInsets

    The new content edge insets value.

    shape

    The shape for the content edge insets.

    mode

    The mode for the content edge insets.

  • Undocumented

    Declaration

    Objective-C

    - (void)setHitAreaInsets:(UIEdgeInsets)hitAreaInsets;
  • Sets the @c hitAreaInsets value when the button has the specified @c shape and @c mode.

    Declaration

    Objective-C

    - (void)setHitAreaInsets:(UIEdgeInsets)hitAreaInsets
                    forShape:(MDCFloatingButtonShape)shape
                      inMode:(MDCFloatingButtonMode)mode;

    Parameters

    hitAreaInsets

    The new hit area insets value.

    shape

    The shape for the hit area insets.

    mode

    The mode for the hit area insets.

  • Expand this button to its unscaled (normal) size.

    Note

    This method will modify the transform property of the button. Apple’s documentation about UIView frames and transforms states that whenever the transform is not the identity transform, the frame is undefined and should be ignored. https://developer.apple.com/documentation/uikit/uiview/1622621-frame

    Declaration

    Objective-C

    - (void)expand:(BOOL)animated completion:(void (^_Nullable)(void))completion;

    Parameters

    animated

    YES if the size change should be animated.

    completion

    a completion block to call after the size change is complete.

  • Collapses this button so that it becomes smaller than 0.1% of its normal size.

    Note

    This method will modify the transform property of the button. Apple’s documentation about UIView frames and transforms states that whenever the transform is not the identity transform, the frame is undefined and should be ignored. https://developer.apple.com/documentation/uikit/uiview/1622621-frame

    Declaration

    Objective-C

    - (void)collapse:(BOOL)animated completion:(void (^_Nullable)(void))completion;

    Parameters

    animated

    YES if the size change should be animated.

    completion

    a completion block to call after the size change is complete.