mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
#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.
40 lines
1.4 KiB
Markdown
40 lines
1.4 KiB
Markdown
### 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:
|
|
|
|
```bash
|
|
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.
|
|
|
|
<!--<div class="material-code-render" markdown="1">-->
|
|
#### Swift
|
|
```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
|
|
|
|
```objc
|
|
// 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];
|
|
```
|
|
<!--</div>-->
|