Andrew Overton eaf2489303
[Dialogs, TextFields] Update docs (#7209)
#7187 and #7184 graduated Buttons and TextFields theming extensions to ready, but didn't update the docs. Similarly, #7190, which has not yet been merged in, is not updating the docs to reflect the graduation of the Dialogs theming extension to ready.

This PR updates docs for Dialogs and TextFields theming extensions to reflect them being marked ready. Once #7190 is merged in the Dialogs changes here will be accurate.

I will address the out-of-date Buttons docs once #7206 is merged in.
2019-04-22 14:12:04 -04:00

1.4 KiB

Theming Extensions

You can theme an MDCTextField using the TextFields theming extension. To add the theming extension to your project add the following line to your Podfile:

pod 'MaterialComponents/TextFields+Theming'

Then import the theming extension and the MDCContainerScheme and create an MDCContainerScheme instance. A container scheme defines schemes for subsystems like Color and Typography. Finally, call theming methods on the theming extension of your MDCTextInputController instance.

Swift

// Step 1: Import the TextFields theming extension and container scheme
import MaterialComponents.MaterialTextFields_Theming
import MaterialComponents.MaterialContainerScheme

// Step 2: Create or get a container scheme
let containerScheme = MDCContainerScheme()

// Step 3: Apply the container scheme to your component using the desired alwert style
textInputController.applyTheme(withScheme: containerScheme)

Objective-C

// Step 1: Import the TextField theming extension and container scheme
#import "MaterialTextFields+Theming.h"
#import "MaterialContainerScheme.h"

// Step 2: Create or get a container scheme
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];

// Step 3: Apply the container scheme to your component using the desired alert style
[textInputController applyThemeWithScheme:containerScheme];