Skip to content

Releases: material-components/material-components-ios

v84.1.0

06 May 21:45
Compare
Choose a tag to compare

This minor release adds enhancements to PageControl and Ink, bug fixes for FlexibleHeader, Ink, NavigationBar, and Ripple, and additional test coverage for ActionSheet and NavigationBar.

New features

Ink

MDCInkTouchController now gives users the ability to require that UIScrollView gesture recognizers fail before the ink animation is triggered. (#7315)

inkTouchController.requiresFailureOfScrollViewGestures = YES;

API changes

Ink

new property: requiresFailureOfScrollViewGestures in MDCInkTouchController

Changes

ActionSheet

BottomNavigation

FlexibleHeader

Ink

NavigationBar

PageControl

Ripple

v84.0.0

02 May 20:29
Compare
Choose a tag to compare

This release corrected a TextFields accessibility behavior, added Ripple to Chips, and added
additional delegate calls to BottomSheet.

Theming docs for multiple components were added, including Chips, Dialogs, and Cards.

Breaking changes

TextField

The VoiceOver behavior of MDCTextField was modified. Much of the information previously returned by
-accessibilityValue is now being returned by -accessibilityLabel. There is now a , that
results in a pause between the label and the helper text.

Searches for MDCTextFields in your view hiearchy with accessiblity value must be changed to searches
for the MDCTextField's accessibility label. The label now also has a inserted , too.

For example an EarlGrey matcher needs to be adjusted from

EarlGrey
      .selectElement(with: grey_accessibilityValue("Phone Number XXX-XXXX")

To:

EarlGrey
      .selectElement(with: grey_accessibilityLabel("Phone Number, XXX-XXXX")

More information can be found in the PR

New features

Dialog theming

Moved from beta to ready

Bottom Sheet

All methods in the MDCBottomSheetControllerDelegate protocol were marked optional.

Two new methods were added to convey state changes and scroll events.

- (void)bottomSheetControllerDidChangeYOffset:(MDCBottomSheetController *)controller
                                      yOffset:(CGFloat)yOffset {
  NSLog(@"bottom sheet Y offset changed: %f", yOffset);
}
- (void)bottomSheetControllerStateChanged:(MDCBottomSheetController *)controller
                                    state:(MDCSheetState)state {
  NSLog(@"bottom sheet state changed to: %lu", (unsigned long)state);
}

Chips

Ripple support was added.

  chipView.enableRippleBehavior = YES;

API changes

BottomSheet

MDCBottomSheetControllerDelegate

new method: -bottomSheetControllerStateChanged:state: in MDCBottomSheetControllerDelegate

new method: -bottomSheetControllerDidChangeYOffset:yOffset: in MDCBottomSheetControllerDelegate

modified method: -bottomSheetControllerDidDismissBottomSheet: in MDCBottomSheetControllerDelegate

Type of change: Swift declaration
From: func bottomSheetControllerDidDismissBottomSheet(_ controller: MDCBottomSheetController)
To: optional func bottomSheetControllerDidDismissBottomSheet(_ controller: MDCBottomSheetController)

MDCBottomSheetPresentationControllerDelegate

new method: -bottomSheetDidChangeYOffset:yOffset: in MDCBottomSheetPresentationControllerDelegate

modified method: -bottomSheetWillChangeState:sheetState: in MDCBottomSheetPresentationControllerDelegate

Type of change: Declaration
From: - (void)bottomSheetWillChangeState:(nonnull MDCBottomSheetPresentationController *)bottomSheet sheetState:(MDCSheetState)sheetState;
To: - (void)bottomSheetWillChangeState: (nonnull MDCBottomSheetPresentationController *)bottomSheet sheetState:(MDCSheetState)sheetState;

Chips

MDCChipView

new property: enableRippleBehavior in MDCChipView

modified class: MDCChipView

Type of change: Declaration
From: `@interface MDCChipView : UIControl /* A UIImageView that leads the title label. */ @Property(nonatomic, readonly, nonnull) IBInspectable UIImageView imageView; / A UIImageView that leads the title label. Appears in front of the imageView. Only visible when the chip is selected. This image view is typically used to show some icon that denotes the chip as selected, such as a check mark. If imageView has no image then the chip will require resizing when selected or deselected to account for the changing visibility of selectedImageView. */ @Property(nonatomic, readonly, nonnull) IBInspectable UIImageView selectedImageView; / A UIView that trails the title label. It will be given a size based on the value returned from sizeThatFits:. */ @Property(nonatomic, strong, nullable) IBInspectable UIView accessoryView; / The title label. @note The title color is controlled by setTitleColor:forState:. @note The title font is controlled by setTitleFont. */ @Property(nonatomic, readonly, nonnull) IBInspectable UILabel titleLabel; / Padding around the chip content. Each subview can be further padded with their invidual padding property. The chip uses this property to determine intrinsicContentSize and sizeThatFits. Defaults to (4, 4, 4, 4). / @Property(nonatomic, assign) UIEdgeInsets contentPadding UI_APPEARANCE_SELECTOR; / Padding around the image view. Only used if the image view has a non-nil image. The chip uses this property to determine intrinsicContentSize and sizeThatFits. Defaults to (0, 0, 0, 0). / @Property(nonatomic, assign) UIEdgeInsets imagePadding UI_APPEARANCE_SELECTOR; / Padding around the accessory view. Only used if the accessory view is non-nil. The chip uses this property to determine intrinsicContentSize and sizeThatFits. Defaults to (0, 0, 0, 0). / @Property(nonatomic, assign) UIEdgeInsets accessoryPadding UI_APPEARANCE_SELECTOR; / Padding around the title. The chip uses this property to determine intrinsicContentSize and sizeThatFits. Defaults to (3, 8, 4, 8). The top padding is shorter so the default height of a chip is 32 pts. / @Property(nonatomic, assign) UIEdgeInsets titlePadding UI_APPEARANCE_SELECTOR; / Font used to render the title. If nil, the chip will use the system font. / @Property(nonatomic, strong, nullable) UIFont titleFont UI_APPEARANCE_SELECTOR; / The color of the ink ripple. / @Property(nonatomic, strong, null_resettable) UIColor inkColor UI_APPEARANCE_SELECTOR __deprecated_msg("Use setInkColor:forState:"); / The shape generator used to define the chip's shape. / @Property(nullable, nonatomic, strong) id shapeGenerator UI_APPEARANCE_SELECTOR; / Indicates whether the chip should automatically update its font when the device’s UIContentSizeCategory is changed. This property is modeled after the adjustsFontForContentSizeCategory property in the UIContentSizeCategoryAdjusting protocol added by Apple in iOS 10.0. If set to YES, this button will base its text font on MDCFontTextStyleButton. Default value is NO. / @Property(nonatomic, readwrite, setter=mdc_setAdjustsFontForContentSizeCategory:) BOOL mdc_adjustsFontForContentSizeCategory UI_APPEARANCE_SELECTOR; / The minimum dimensions of the Chip. A non-positive value for either height or width is equivalent to no minimum for that dimension. Defaults to a minimum height of 32 points, and no minimum width. / @Property(nonatomic, assign) CGSize minimumSize UI_APPEARANCE_SELECTOR; / Custom insets to use when computing touch targets. A positive inset value will shrink the hit area for the Chip. / @Property(nonatomic, assign) UIEdgeInsets hitAreaInsets; / A color used as the chip's @c backgroundColor for @c state. If no background color has been set for a given state, the returned value will fall back to the value set for UIControlStateNormal. @param state The control state. @return The background color. */ - (nullable UIColor )backgroundColorForState:(UIControlState)state; / A color used as the chip's @c backgroundColor. Defaults to blue. @param backgroundColor The background color. @param state The control state. */ - (void)setBackgroundColor:(nullable UIColor )backgroundColor forState:(UIControlState)state UI_APPEARANCE_SELECTOR; / Returns the border color for a particular control state. If no border width has been set for a given state, the returned value will fall back to the value set for UIControlStateNormal. @param state The control state. @return The border color for the requested state. */ - (nullable UIColor )borderColorForState:(UIControlState)state; / Sets the border color for a particular control state. @param borderColor The border color. @param state The control state. */ - (void)setBorderColor:(nullable UIColor )borderColor forState:(UIControlState)state UI_APPEARANCE_SELECTOR; / Returns the border width for a particular control state. If no border width has been set for a given state, the returned value will fall back to the value set for UIControlStateNormal. @param state The control state. @return The border width for the requested state. / - (CGFloat)borderWidthForState:(UIControlState)state; / Sets the border width for a particular control state. @param borderWidth The border width. @param state The control state. / - (void)setBorderWidth:(CGFloat)borderWidth forState:(UIControlState)state UI_APPEARANCE_SELECTOR; / Returns the elevation for a particular control state. If no elevation has been set for a given state, the returned value will fall back to the value set for UIControlStateNormal. @param state The control state. @return The elevation for the requested state. / - (MDCShadowElevation)elevationForState:(UIControlState)state; / Sets the elevation for a particular control state. @param elevation The elevation. @param state The control state. / - (void)setElevation:(MDCShadowElevation)elevation forState:(UIControlState)state UI_APPEARANCE_SELECTOR; / Returns the ink color for a particular control state. If no ink color has been set for a given state, the returned value will fall back to the value set for UIControlStateNormal. Defaults to nil. When nil MDCInkView.defaultInkColor is used. @param state The control state. @return The ink color for the requested state. */ - (nullable UIColor )inkColorForState:(UIControlState)state; / Sets the ink color for a particular control stat...
Read more

v83.0.2

30 Apr 22:23
Compare
Choose a tag to compare

This patch release fixes a crashing bug with ActionSheet during rotation.

Component changes

ActionSheet

v83.0.1

26 Apr 20:23
Compare
Choose a tag to compare

This patch release resolves some missing content from the theming extension documentation and
removes a broken link.

v83.0.0

23 Apr 19:38
Compare
Choose a tag to compare

This major release graduates most Theming Extensions from Beta and includes a breaking change for
AppBar's imports. All Themer APIs have been annotated as "to be deprecated" in lieu of Theming
extensions. The following Theming Extensions are now generally available:

  • ActionSheet
  • AppBar
  • Buttons
  • Cards
  • Chips
  • Tabs
  • TextFields
  • Container scheme

Breaking changes

AppBar's Theming extension header has changed, so you may need to update your import statements
accordingly:

Swift

- import MaterialComponents.MaterialAppBar_MaterialTheming
+ import MaterialComponents.MaterialAppBar_Theming

ObjC

- #import "MaterialAppBar+MaterialTheming.h"
+ #import "MaterialAppBar+Theming.h"

API changes

ActivityIndicator+ColorThemer

MDCActivityIndicatorColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toActivityIndicator: in MDCActivityIndicatorColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCActivityIndicatorColorThemer
To: c:objc(cy)MDCActivityIndicatorColorThemer@ToBeDeprecated

AppBar+ColorThemer

MDCAppBarColorThemer(ToBeDeprecated)

modified class method: +applySurfaceVariantWithColorScheme:toAppBarViewController: in MDCAppBarColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCAppBarColorThemer
To: c:objc(cy)MDCAppBarColorThemer@ToBeDeprecated

modified class method: +applyColorScheme:toAppBarViewController: in MDCAppBarColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCAppBarColorThemer
To: c:objc(cy)MDCAppBarColorThemer@ToBeDeprecated

AppBar+TypographyThemer

MDCAppBarTypographyThemer(ToBeDeprecated)

modified class method: +applyTypographyScheme:toAppBarViewController: in MDCAppBarTypographyThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCAppBarTypographyThemer
To: c:objc(cy)MDCAppBarTypographyThemer@ToBeDeprecated

BottomAppBar+ColorThemer

MDCBottomAppBarColorThemer(ToBeDeprecated)

modified class method: +applySurfaceVariantWithSemanticColorScheme:toBottomAppBarView: in MDCBottomAppBarColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCBottomAppBarColorThemer
To: c:objc(cy)MDCBottomAppBarColorThemer@ToBeDeprecated

BottomNavigation+ColorThemer

MDCBottomNavigationBarColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toBottomNavigation: in MDCBottomNavigationBarColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCBottomNavigationBarColorThemer
To: c:objc(cy)MDCBottomNavigationBarColorThemer@ToBeDeprecated

BottomNavigation+TypographyThemer

MDCBottomNavigationBarTypographyThemer(ToBeDeprecated)

new category: MDCBottomNavigationBarTypographyThemer(ToBeDeprecated)

modified class method: +applyTypographyScheme:toBottomNavigationBar: in MDCBottomNavigationBarTypographyThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCBottomNavigationBarTypographyThemer
To: c:objc(cy)MDCBottomNavigationBarTypographyThemer@ToBeDeprecated

BottomSheet+ShapeThemer

MDCBottomSheetControllerShapeThemer(ToBeDeprecated)

new category: MDCBottomSheetControllerShapeThemer(ToBeDeprecated)

modified class method: +applyShapeScheme:toBottomSheetController: in MDCBottomSheetControllerShapeThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCBottomSheetControllerShapeThemer
To: c:objc(cy)MDCBottomSheetControllerShapeThemer@ToBeDeprecated

ButtonBar+ColorThemer

MDCButtonBarColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toButtonBar: in MDCButtonBarColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCButtonBarColorThemer
To: c:objc(cy)MDCButtonBarColorThemer@ToBeDeprecated

ButtonBar+TypographyThemer

MDCButtonBarTypographyThemer(ToBeDeprecated)

new category: MDCButtonBarTypographyThemer(ToBeDeprecated)

modified class method: +applyTypographyScheme:toButtonBar: in MDCButtonBarTypographyThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCButtonBarTypographyThemer
To: c:objc(cy)MDCButtonBarTypographyThemer@ToBeDeprecated

Buttons+ButtonThemer

MDCOutlinedButtonThemer(ToBeDeprecated)

new category: MDCOutlinedButtonThemer(ToBeDeprecated)

modified class method: +applyScheme:toButton: in MDCOutlinedButtonThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCOutlinedButtonThemer
To: c:objc(cy)MDCOutlinedButtonThemer@ToBeDeprecated

MDCContainedButtonThemer(ToBeDeprecated)

new category: MDCContainedButtonThemer(ToBeDeprecated)

modified class method: +applyScheme:toButton: in MDCContainedButtonThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCContainedButtonThemer
To: c:objc(cy)MDCContainedButtonThemer@ToBeDeprecated

MDCTextButtonThemer(ToBeDeprecated)

new category: MDCTextButtonThemer(ToBeDeprecated)

modified class method: +applyScheme:toButton: in MDCTextButtonThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCTextButtonThemer
To: c:objc(cy)MDCTextButtonThemer@ToBeDeprecated

MDCFloatingActionButtonThemer(ToBeDeprecated)

new category: MDCFloatingActionButtonThemer(ToBeDeprecated)

modified class method: +applyScheme:toButton: in MDCFloatingActionButtonThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCFloatingActionButtonThemer
To: c:objc(cy)MDCFloatingActionButtonThemer@ToBeDeprecated

Buttons+ColorThemer

MDCOutlinedButtonColorThemer(ToBeDeprecated)

new category: MDCOutlinedButtonColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toButton: in MDCOutlinedButtonColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCOutlinedButtonColorThemer
To: c:objc(cy)MDCOutlinedButtonColorThemer@ToBeDeprecated

MDCContainedButtonColorThemer(ToBeDeprecated)

new category: MDCContainedButtonColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toButton: in MDCContainedButtonColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCContainedButtonColorThemer
To: c:objc(cy)MDCContainedButtonColorThemer@ToBeDeprecated

MDCTextButtonColorThemer(ToBeDeprecated)

new category: MDCTextButtonColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toButton: in MDCTextButtonColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCTextButtonColorThemer
To: c:objc(cy)MDCTextButtonColorThemer@ToBeDeprecated

MDCFloatingButtonColorThemer(ToBeDeprecated)

new category: MDCFloatingButtonColorThemer(ToBeDeprecated)

modified class method: +applySemanticColorScheme:toButton: in MDCFloatingButtonColorThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCFloatingButtonColorThemer
To: c:objc(cy)MDCFloatingButtonColorThemer@ToBeDeprecated

Buttons+ShapeThemer

MDCFloatingButtonShapeThemer(ToBeDeprecated)

new category: MDCFloatingButtonShapeThemer(ToBeDeprecated)

modified class method: +applyShapeScheme:toButton: in MDCFloatingButtonShapeThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCFloatingButtonShapeThemer
To: c:objc(cy)MDCFloatingButtonShapeThemer@ToBeDeprecated

MDCButtonShapeThemer(ToBeDeprecated)

new category: MDCButtonShapeThemer(ToBeDeprecated)

modified class method: +applyShapeScheme:toButton: in MDCButtonShapeThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCButtonShapeThemer
To: c:objc(cy)MDCButtonShapeThemer@ToBeDeprecated

Buttons+TypographyThemer

MDCButtonTypographyThemer(ToBeDeprecated)

new category: MDCButtonTypographyThemer(ToBeDeprecated)

modified class method: +applyTypographyScheme:toButton: in MDCButtonTypographyThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCButtonTypographyThemer
To: c:objc(cy)MDCButtonTypographyThemer@ToBeDeprecated

Cards+CardThemer

MDCCardThemer(ToBeDeprecated)

new category: MDCCardThemer(ToBeDeprecated)

modified class method: +applyOutlinedVariantWithScheme:toCardCell: in MDCCardThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCCardThemer
To: c:objc(cy)MDCCardThemer@ToBeDeprecated

modified class method: +applyScheme:toCard: in MDCCardThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCCardThemer
To: c:objc(cy)MDCCardThemer@ToBeDeprecated

modified class method: +applyOutlinedVariantWithScheme:toCard: in MDCCardThemer(ToBeDeprecated)

Type of change: parent.usr
From: c:objc(cs)MDCCardThemer
To: c:objc(cy)MDCCardThemer@ToBeDeprecated

modified class method: +applyScheme:toCardCell: in MDCCardThemer(ToBeDeprecated)

| Type of change: | parent.usr |
|--...

Read more

v82.0.0

17 Apr 19:38
Compare
Choose a tag to compare

In this major release, we dropped support for iOS 8 in all components. We also introduced new method and properties for AppBar, BottomSheet and NavigationDrawer.

Breaking changes

This release drops support for iOS 8 and the library, catalog, examples, and demos may no longer build for iOS 8 targets or may crash even if building succeeds. Clients will need to set their minimum deployment targets to iOS 9 or later.

New features

Add support for MDCAppBarNavigationController delegate to pick a tracking scroll view

An optional delegate method was added to allow clients to specify the controller's tracking scroll view. The delegate may return nil if no appropriate tracking scroll view is present.

Swift

func appBarNavigationController(_ navigationController: MDCAppBarNavigationController,
                              trackingScrollViewFor trackingScrollViewForViewController: UIViewController,
                              suggestedTrackingScrollView: UIScrollView?) -> UIScrollView? {
  return trackingScrollView
}

Objective-C

- (UIScrollView *)appBarNavigationController:(MDCAppBarNavigationController *)navigationController
                  trackingScrollViewForViewController:(UIViewController *)viewController
                          suggestedTrackingScrollView:(UIScrollView *)scrollView {
  return self.trackingScrollView;
}

flashScrollIndicators in BottomSheet

MDCBottomSheetController has a new API that will flash the scroll indicators when the view appears.

Swift

bottomSheet.shouldFlashScrollIndicatorsOnAppearance = true;

Objective-C

self.bottomSheet.shouldFlashScrollIndicatorsOnAppearance = YES;

maximumInitialDrawerHeight in NavigationDrawer

Clients can now override the initial drawer height on MDCBottomDrawerViewController with a desired height in points.

Swift

bottomDrawer.maximumInitialDrawerHeight = 1000;

Objective-C

self.bottomDrawer.maximumInitialDrawerHeight = 1000;

API changes

AppBar

MDCAppBarNavigationControllerDelegate

new method: -appBarNavigationController:trackingScrollViewForViewController:suggestedTrackingScrollView: in MDCAppBarNavigationControllerDelegate

BottomSheet

MDCBottomSheetController

new property: shouldFlashScrollIndicatorsOnAppearance in MDCBottomSheetController

NavigationDrawer

MDCBottomDrawerViewController

new property: maximumInitialDrawerHeight in MDCBottomDrawerViewController

MDCBottomDrawerPresentationController

new property: maximumInitialDrawerHeight in MDCBottomDrawerPresentationController

Tabs+Theming

New extension.

Component changes

Multi-component breaking changes

Changes

AppBar

BottomNavigation

BottomSheet

Buttons

Dialogs

NavigationDrawer

Tabs

TextFields

Multi-component changes

v81.1.0

09 Apr 19:52
Compare
Choose a tag to compare

In this minor release we introduced a new beta component, Banner. We also added Ripple support for Buttons, along with text contrast improvements to Tabs and Bottom Navigation.

New features

Ripple integration with Buttons

Buttons now support the latest iteration of the Material Design "ripple" effect. Clients can test this
functionality by setting enableRippleBehavior to YES.

Swift

myButton.enableRippleBehavior = true

Objective-C

self.myButton.enableRippleBehavior = YES;

API changes

Banner

New component.

Component changes

Changes

ActionSheet

Banner

BottomNavigation

Buttons

NavigationDrawer

Tabs

TextFields

Multi-component changes

v81.0.0

02 Apr 15:31
Compare
Choose a tag to compare

This major release introduces the Ripple component and integrates it with Cards. There are also
visual changes for badges on Tabs, multi-line title support for Bottom Navigation, and improved
Dynamic Type support for Buttons and Feature Highlight.

Breaking changes

The appearance of badges on MDCTabBar has changed. Badges now appear similar to those on
MDCBottomNavigationBar and are, by default, a red "pill" shape with white text. The color can be
customized by assigning a value to - UITabBarItem.badgeColor.

New features

Ripple integration with Cards

Cards now support the latest iteration of the Material Design "ripple" effect. Clients can test this
functionality by setting enableRippleBehavior to YES.

Swift

myCard.enableRippleBehavior = true

Objective-C

self.myCard.enableRippleBehavior = YES;

Multi-line title support in Bottom Navigation

Clients can enable multi-line title support in MDCBottomNavigationBar by setting
titlesNumberOfLines to a value other than 1. This API should be used only as a last resort, when
it is not possible to provide shorter titles that fit within the available screen space.

Swift

bottomNavigationBar.titlesNumberOfLines = 0

Objective-C

self.bottomNavigationBar.titlesNumberOfLines = 0;

Automatic Dynamic Type font adjustment in Feature Highlight and Buttons

Buttons and Feature Highlight now support enabling automatic font size adjustment for Dynamic Type
when the fonts used by the components have scaling curves attached using MDCFontScaler. Both
components use the new scaling if mdc_adjustsFontForContentSizeCategory is set to YES.

Swift

// The new TypographyScheme defaults provide scaled fonts
containerScheme.typographyScheme = MDCTypographyScheme.init(defaults: .material201902)
let button = MDCButton()
button.applyContainedTheme(withScheme: containerScheme)
button.setTitle("Submit", for: UIControlState())
// Enable automatic font adjustment
button.mdc_adjustsFontForContentSizeCategory = true

Objective-C

// The new TypographyScheme defaults provide scaled fonts
self.containerScheme.typographyScheme = 
    [[MDCTypographyScheme alloc] initWithDefaults: MDCTypographySchemeDefaultsMaterial201804];
MDCButton *button = [[MDCButton alloc] init];
[button applyContainedThemeWithScheme:self.containerScheme];
[button setTitle:@"Submit" forState:UIControlStateNormal];
// Enable automatic font adjustment
button.mdc_adjustsFontForContentSizeCategory = YES;

API changes

Banner

MDCBannerView

new property: textLabel in MDCBannerView

new property: imageView in MDCBannerView

new property: leadingButton in MDCBannerView

new property: trailingButton in MDCBannerView

removed property: buttons in MDCBannerView

removed property: text in MDCBannerView

removed property: image in MDCBannerView

removed property: numberOfButtons in MDCBannerView

modified class: MDCBannerView

Type of change: Declaration
From: @interface MDCBannerView : UIView @property(nonatomic, copy, nonnull) NSString *text; @property(nonatomic, strong, nullable) UIImage *image; // default is nil @property(nonatomic, assign) NSUInteger numberOfButtons; // default is 1 /** The buttons representing the banner's actions. */ @property(nonatomic, readonly, copy, nonnull) NSArray<MDCButton *> *buttons; @end
To: @interface MDCBannerView : UIView /** A view that displays the text on a @c MDCBannerView The properties of @c textLabel can be used to configure the text shown on @c MDCBannerView. */ @property(nonatomic, readonly, strong, nonnull) UILabel *textLabel; /** A view that displays the image on a @c MDCBannerView. The properties of @c imageView can be used to configure the image shown on @c MDCBannerView. If @c imageView 's own property @c image is @c nil, this view won't show on the @c MDCBannerView. */ @property(nonatomic, readonly, strong, nonnull) UIImageView *imageView; /** A leading button that displays on a @c MDCBannerView. This @c leadingButton is displayed on the leading edge of the view. If it does not fit on the same row as @c trailingButton, it will be placed above @c trailingButton. */ @property(nonatomic, readonly, strong, nonnull) MDCButton *leadingButton; /**s A trailing button that displays on a @c MDCBannerView. This @c trailingButton is displayed on the trailing edge of the view. If it does not fit on the same row as @c leadingButton, it will be placed shows below @c leadingButton. */ @property(nonatomic, readonly, strong, nonnull) MDCButton *trailingButton; @end

BottomNavigation

MDCBottomNavigationBar

new property: titlesNumberOfLines in MDCBottomNavigationBar

Buttons

MDCButton

new property: mdc_legacyFontScaling in MDCButton

Cards

MDCCardCollectionCell

new property: rippleView in MDCCardCollectionCell

new property: dragged in MDCCardCollectionCell

new property: enableRippleBehavior in MDCCardCollectionCell

modified class: MDCCardCollectionCell

Type of change: Declaration
From: `@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; /* 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; / 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 shapeGenerator; /* 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. */ - (null...
Read more

v80.0.0

26 Mar 16:36
Compare
Choose a tag to compare

80.0.0

This major release introduces Dynamic Type support for Typography Schemes as well as
UIFontMetrics-like support for Dynamic Type for Material Typography. It also includes snapshot tests
for additional components and less-restrictive badging for Tabs.

Breaking changes

MDCTypographyScheming has a new non-optional API, mdc_adjustsFontForContentSizeCategory that is
YES if the returned fonts should use the new Dynamic Type APIs available from Material Typography.
Existing implementations may wish to migrate (at least initially) by returning NO as a read-only
value until support can be added.

- (void)mdc_adjustsFontForContentSizeCategory {
  return NO;
}
public var mdc_adjustsFontForContentSizeCategory: Bool {
  return false;
}

New features

Improved Dynamic Type Support

The Typography and TypographyScheme components have been updated for improved Dynamic Type support.
Most clients will make use of this support through MDCTypographyScheme, though it is possible
to create scalable fonts manually via MDCFontScaler within Typography. The new scaling curves have
been updated for last year's refresh of Material Design typography and font values.

Objective-C

// Typography Scheme is the most typical way to receive scalable fonts.
MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] initWithDefaults:MDCTypographySchemeDefaultsMaterial201902];
UIFont *scaledBody1Font = [typographyScheme.body1 mdc_scaledFontForCurrentSizeCategory];

// If Typography Schemes aren't used, it's possible to create the fonts manually.
// Initial set-up to apply scaling curves to a base UIFont.
UIFont *baseFont = [UIFont systemFontOfSize:18.0];
MDCFontScaler *body2Scaler = [[MDCFontScaler alloc] initForMaterialTextStyle:MDCTextStyleBody2];
UIFont *scalableFont = [body2Scaler scaledFontWithFont:baseFont];

// Now UIFonts appropriate for Dynamic Type size categories can be created anywhere.
UIFont *baseFontScaledToDefault = [scalableFont mdc_scaledFontAtDefaultSize];
UIFont *baseFontScaledForExtraLarge = [scalableFont mdc_scaledFontForSizeCategory:UIContentSizeCategoryExtraLarge];
UIFont *baseFontScaledForCurrentSizeCategory = [scalableFont mdc_scaledFontForCurrentSizeCategory];

Swift

// Typography Scheme is the most typical way to receive scalable fonts.
let typographyScheme = MDCTypographyScheme(defaults: .material201902)
let scaledBody1Font = typographyScheme.body1.mdc_scaledFontForCurrentSizeCategory()

// If Typography Schemes aren't used, it's possible to create the fonts manually.
// Initial set-up to apply scaling curves to a base UIFont.
let baseFont = UIFont.systemFont(ofSize: 18)
let body2Scaler = MDCFontScaler(forMaterialTextStyle: .body2)
let scalableFont = body2Scaler.scaledFont(with: baseFont)

// Now UIFonts appropriate for Dynamic Type size categories can be created anywhere.
let baseFontScaledToDefault = scalableFont.mdc_scaledFontAtDefaultSize()
let baseFontScaledForExtraLarge = scalableFont.mdc_scaledFont(forSizeCategory: .extraLarge)
let baseFontScaledForCurrentSizeCategory = scalableFont.mdc_scaledFontForCurrentSizeCategory()

API changes

Typography

MDCTextStyleButton

new constant: MDCTextStyleButton

MDCTextStyleCaption

new constant: MDCTextStyleCaption

MDCTextStyleSubtitle2

new constant: MDCTextStyleSubtitle2

MDCTextStyleSubtitle1

new constant: MDCTextStyleSubtitle1

MDCTextStyleBody1

new constant: MDCTextStyleBody1

UIFont(MaterialScalable)

new method: -mdc_scaledFontForCurrentSizeCategory in UIFont(MaterialScalable)

new method: -mdc_scaledFontAtDefaultSize in UIFont(MaterialScalable)

new method: -mdc_scaledFontForSizeCategory: in UIFont(MaterialScalable)

new category: UIFont(MaterialScalable)

new property: mdc_scalingCurve in UIFont(MaterialScalable)

MDCFontScaler

new class method: +scalerForMaterialTextStyle: in MDCFontScaler

new method: -scaledValueForValue: in MDCFontScaler

new class: MDCFontScaler

new method: -init in MDCFontScaler

new method: -initForMaterialTextStyle: in MDCFontScaler

new method: -scaledFontWithFont: in MDCFontScaler

MDCTextStyleHeadline4

new constant: MDCTextStyleHeadline4

MDCTextStyleHeadline3

new constant: MDCTextStyleHeadline3

MDCTextStyleHeadline2

new constant: MDCTextStyleHeadline2

MDCTextStyleHeadline6

new constant: MDCTextStyleHeadline6

MDCTextStyleBody2

new constant: MDCTextStyleBody2

MDCTextStyle

new typedef: MDCTextStyle

MDCTextStyleOverline

new constant: MDCTextStyleOverline

MDCTextStyleHeadline1

new constant: MDCTextStyleHeadline1

MDCTextStyleHeadline5

new constant: MDCTextStyleHeadline5

TypographyScheme

MDCTypographySchemeDefaults

new enum value: MDCTypographySchemeDefaultsMaterial201902 in MDCTypographySchemeDefaults

MDCTypographyScheme

new property: mdc_adjustsFontForContentSizeCategory in MDCTypographyScheme

MDCTypographyScheming

new property: mdc_adjustsFontForContentSizeCategory in MDCTypographyScheming

Component changes

Changes

ActivityIndicator

AppBar

Buttons

HeaderStackView

Ripple

ShapeLibrary

Shapes

Tabs

Typography

schemes/Typography

v79.3.0

20 Mar 16:29
Compare
Choose a tag to compare

79.3.0

This minor release fixes a bug in MDCButton's accessibilityTraits value. A recent change introduced
a bug that disabled the default behavior of accessibilityTraits and so they would not
automatically be updated when the button was disabled.

Changes

Buttons