Note: This documentation refers to legacy APIs that will eventually be deprecated. Please consider reading the updated theming documentation instead.
You can theme an MDCButton to match one of the Material Design button styles using your app's schemes in the ButtonThemer extension.
You must first add the ButtonThemer extension to your project:
pod 'MaterialComponents/Buttons+ButtonThemer'
You can then import the extension and create an MDCButtonScheme instance. A button scheme defines the design parameters that you can use to theme your buttons.
// Step 1: Import the ButtonThemer extension import MaterialComponents.MaterialButtons_ButtonThemer // Step 2: Create or get a button scheme let buttonScheme = MDCButtonScheme() // Step 3: Apply the button scheme to your component using the desired button style
// Step 1: Import the ButtonThemer extension #import "MaterialButtons+ButtonThemer.h" // Step 2: Create or get a button scheme MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init]; // Step 3: Apply the button scheme to your component using the desired button style
To theme a button as a Material Design text button, use MDCTextButtonThemer.
MDCTextButtonThemer.applyScheme(buttonScheme, to: button)
[MDCTextButtonThemer applyScheme:buttonScheme toButton:button];
To theme a button as a Material Design outlined button, use MDCOutlinedButtonThemer with an MDCButton.
MDCOutlinedButtonThemer.applyScheme(buttonScheme, to: button)
[MDCOutlinedButtonThemer applyScheme:buttonScheme toButton:button];
To theme a button as a Material Design contained button, use MDCContainedButtonThemer.
MDCContainedButtonThemer.applyScheme(buttonScheme, to: button)
[MDCContainedButtonThemer applyScheme:buttonScheme toButton:button];
To theme a button as a Material Design floating action button, use MDCFloatingActionButtonThemer with an MDCFloatingButton.
MDCFloatingActionButtonThemer.applyScheme(buttonScheme, to: button)
[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:button];