Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Slider] Split the documentation into separate articles and run the r…
…eadme generator. (#3626)
- Loading branch information
Showing
7 changed files
with
188 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Slider | ||
|
||
<div class="article__asset article__asset--screenshot"> | ||
<img src="docs/assets/slider.png" alt="Slider" width="375"> | ||
</div> | ||
|
||
The `MDCSlider` object is a Material Design control used to select a value from a continuous range | ||
or discrete set of values. | ||
|
||
## Design & API documentation | ||
|
||
* [Material Design guidelines: Sliders](https://material.io/go/design-sliders) | ||
* [API: MDCSlider](https://material.io/components/ios/catalog/sliders/api-docs/Classes/MDCSlider.html) | ||
|
||
<!-- toc --> | ||
|
||
- - - | ||
|
||
## Installation | ||
|
||
- [Typical installation](../../../docs/component-installation.md) | ||
|
||
## Usage | ||
|
||
- [Typical use](typical-use.md) | ||
- [Stateful APIs](stateful-apis.md) | ||
- [Differences from UISlider](differences-from-uislider.md) | ||
|
||
## Extensions | ||
|
||
- [Color Theming](color-theming.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### Differences from UISlider | ||
|
||
Does not have api to: | ||
|
||
- set right and left icons | ||
- set the thumb image | ||
- set the right and left track images (for a custom track) | ||
- set the right (background track) color | ||
|
||
Same features: | ||
|
||
- set color for thumb via @c thumbColor | ||
- set color of track via @c trackColor | ||
|
||
New features: | ||
|
||
- making the slider a snap to discrete values via property numberOfDiscreteValues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### Stateful APIs | ||
|
||
`MDCSlider` exposes stateful APIs to customize the colors for different control states. In order to use this API you must enable `statefulAPIEnabled` on your `MDCSlider` instances. | ||
|
||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
|
||
```swift | ||
let slider = MDCSlider() | ||
slider.isStatefulAPIEnabled = true | ||
|
||
// Setting a thumb color for selected state. | ||
slider.setThumbColor(.red, for: .selected) | ||
``` | ||
|
||
#### Objective C | ||
|
||
```objc | ||
MDCSlider *slider = [[MDCSlider alloc] init]; | ||
slider.statefulAPIEnabled = YES; | ||
|
||
// Setting a thumb color for selected state. | ||
[slider setThumbColor:[UIColor redColor] forState:UIControlStateSelected]; | ||
``` | ||
<!--</div>--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
### Typical use | ||
|
||
MDCSlider can be be used like a standard `UIControl`. | ||
|
||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
|
||
```swift | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
let slider = MDCSlider(frame: CGRect(x: 50, y: 50, width: 100, height: 27)) | ||
slider.addTarget(self, | ||
action: #selector(didChangeSliderValue(senderSlider:)), | ||
for: .valueChanged) | ||
view.addSubview(slider) | ||
} | ||
|
||
func didChangeSliderValue(senderSlider:MDCSlider) { | ||
print("Did change slider value to: %@", senderSlider.value) | ||
} | ||
``` | ||
|
||
#### Objective C | ||
|
||
```objc | ||
- (void)viewDidLoad { | ||
MDCSlider *slider = [[MDCSlider alloc] initWithFrame:CGRectMake(50, 50, 100, 27)]; | ||
[slider addTarget:self | ||
action:@selector(didChangeSliderValue:) | ||
forControlEvents:UIControlEventValueChanged]; | ||
[self.view addSubview:slider]; | ||
} | ||
|
||
- (void)didChangeSliderValue:(MDCSlider *)slider { | ||
NSLog(@"did change %@ value: %f", NSStringFromClass([slider class]), slider.value); | ||
} | ||
``` | ||
<!--</div>--> |