Note: This documentation refers to legacy APIs that will eventually be deprecated. Please consider reading the updated theming documentation instead.
You can theme buttons with your app's color scheme using the ColorThemer extension.
You must first add the Color Themer extension to your project:
pod 'MaterialComponents/Buttons+ColorThemer'
// Step 1: Import the ColorThemer extension
import MaterialComponents.MaterialButtons_ColorThemer
// Step 2: Create or get a color scheme
let colorScheme = MDCSemanticColorScheme()
// Step 3: Apply the color scheme to your component using the desired button style
MDCContainedButtonColorThemer.applySemanticColorScheme(colorScheme, to: component)
MDCFloatingButtonColorThemer.applySemanticColorScheme(colorScheme, to: component)
MDCTextButtonColorThemer.applySemanticColorScheme(colorScheme, to: component)
// Step 1: Import the ColorThemer extension
#import "MaterialButtons+ColorThemer.h"
// Step 2: Create or get a color scheme
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
// Step 3: Apply the color scheme to your component using the desired button style
[MDCContainedButtonColorThemer applySemanticColorScheme:colorScheme
toButton:component];
[MDCFloatingButtonColorThemer applySemanticColorScheme:colorScheme
toButton:component];
[MDCTextButtonColorThemer applySemanticColorScheme:colorScheme
toButton:component];