MDCTabBar

@interface MDCTabBar : UIView <UIBarPositioning>

A material tab bar for switching between views of grouped content.

Clients are responsible for responding to changes to the selected tab and updating the selected tab as necessary.

Note: This class is not intended to be subclassed.

  • The default height for the tab bar with a given position and item appearance.

    Declaration

    Objective-C

    + (CGFloat)defaultHeightForBarPosition:(UIBarPosition)position
                            itemAppearance:(MDCTabBarItemAppearance)appearance;
  • The default height for the tab bar in the top position, given an item appearance.

    Declaration

    Objective-C

    + (CGFloat)defaultHeightForItemAppearance:(MDCTabBarItemAppearance)appearance;
  • Items displayed in the tab bar.

    The bar determines the newly-selected item using the following logic:

    • Reselect the previously-selected item if it’s still present in items after the update.
    • If there was no selection previously or if the old selected item is gone, select the first item. Clients that need empty selection to be preserved across updates to items must manually reset selectedItem to nil after the update.

    Changes to this property are not animated.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nonnull) NSArray<UITabBarItem *> *items;
  • The currently selected item. Setting to nil will clear the selection.

    Changes to selectedItem are not animated.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UITabBarItem *selectedItem;
  • The tab bar’s delegate.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<MDCTabBarDelegate> delegate;
  • Tint color for the tab bar, which determines the color of the tab indicator bar. If selectedItemTintColor is nil, tintColor also affects tinting of selected item titles and images.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *tintColor;
  • Tint color for selected items. If set overrides titleColorForState: and imageTintColorForState: for MDCTabBarItemStateSelected. Returns imageTintColorForState: for MDCTabBarItemStateSelected.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable)
        UIColor *selectedItemTintColor;
  • Tint color for unselected items. If set overrides titleColorForState: and imageTintColorForState: for MDCTabBarItemStateNormal. Returns imageTintColorForState: for MDCTabBarItemStateNormal.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nonnull)
        UIColor *unselectedItemTintColor;
  • Ink color for taps on tab bar items. Default: Semi-transparent white.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nonnull) UIColor *inkColor;
  • Color for the bottom divider. Default: Clear.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nonnull) UIColor *bottomDividerColor;
  • Font used for selected item titles. By default this uses +[MDCTypography buttonFont]. Ignored for bottom-position tab bars.

    Note: Tab sizes are determined based on their unselected state and do not vary based on selection. To avoid clipped layouts and other layout issues, the font provided here should have similar metrics to unselectedItemTitleFont.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nonnull) UIFont *selectedItemTitleFont;
  • Font used for unselected item titles. By default this uses the MDCTypography button font. Ignored for bottom-position tab bars.

    Note: Tab sizes are determined based on their unselected state and do not vary based on selection. To avoid clipped layouts and other layout issues, the font provided here should have similar metrics to selectedItemTitleFont.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nonnull)
        UIFont *unselectedItemTitleFont;
  • Tint color to apply to the tab bar background.

    If nil, the receiver uses the default background appearance. Default: nil.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) UIColor *barTintColor;
  • Horizontal alignment of tabs within the tab bar. Changes are not animated. Default alignment is MDCTabBarAlignmentLeading.

    The default value is based on the position and is recommended for most applications.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCTabBarAlignment alignment;
  • Appearance of tabs within the tab bar. Changes are not animated.

    The default value is based on the position and is recommended for most applications.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCTabBarItemAppearance itemAppearance;
  • Indicates if all tab titles should be uppercased for display. If NO, item titles will be displayed verbatim.

    The default value is based on the position and is recommended for most applications.

    NOTE: This property will be deprecated in a future release. Use titleTextTransform instead. https://github.com/material-components/material-components-ios/issues/2552

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL displaysUppercaseTitles;
  • Defines how tab bar item titles are transformed for display.

    The default value is MDCTabBarTextTransformAutomatic.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        MDCTabBarTextTransform titleTextTransform;
  • Template that defines the appearance of the selection indicator.

    The default indicator template is a fixed-height rectangular bar under the selected tab.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        id<MDCTabBarIndicatorTemplate>
            selectionIndicatorTemplate;
  • Select an item with optional animation. Setting to nil will clear the selection.

    selectedItem must be nil or in items.

    Declaration

    Objective-C

    - (void)setSelectedItem:(nullable UITabBarItem *)selectedItem
                   animated:(BOOL)animated;
  • Updates the alignment with optional animation.

    Declaration

    Objective-C

    - (void)setAlignment:(MDCTabBarAlignment)alignment animated:(BOOL)animated;
  • Sets the color of the title for the specified state.

    If the @c MDCTabBarItemState value is not set, then defaults to a default value. Therefore, at a minimum, you should set the value for MDCTabBarItemStateNormal.

    Declaration

    Objective-C

    - (void)setTitleColor:(nullable UIColor *)color
                 forState:(MDCTabBarItemState)state;
  • Returns the title color associated with the specified state.

    Declaration

    Objective-C

    - (nullable UIColor *)titleColorForState:(MDCTabBarItemState)state;
  • Sets the tint color of the image for the specified state.

    If the @c MDCTabBarItemState value is not set, then defaults to a default value. Therefore, at a minimum, you should set the value for MDCTabBarItemStateNormal.

    Declaration

    Objective-C

    - (void)setImageTintColor:(nullable UIColor *)color
                     forState:(MDCTabBarItemState)state;
  • Returns the image tint color associated with the specified state.

    Declaration

    Objective-C

    - (nullable UIColor *)imageTintColorForState:(MDCTabBarItemState)state;
  • Get the accessibility element representing the given item. Returns nil if item is not in items or if the item is not on screen.

    The accessibility element returned from this method may be used as the focused element after a run loop iteration.

    Declaration

    Objective-C

    - (nullable id)accessibilityElementForItem:(nonnull UITabBarItem *)item;