MDCSlider

@interface MDCSlider : UIControl

A Material slider.

Differences between UISlider and MDCSlider: Does not have api to set right and left icons set the thumb image set the right and left track images (if you wanted a custom track) set the right (background track) color Same features set color for thumb via @c color set color of track via @c trackColor New features making the slider a snap to discrete values via @c numberOfDiscreteValues.

  • When @c YES, the forState: APIs are enabled. Defaults to @c NO.

    Declaration

    Objective-C

    @property (getter=isStatefulAPIEnabled, assign, readwrite, nonatomic)
        BOOL statefulAPIEnabled;
  • The delegate for the slider.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<MDCSliderDelegate> delegate;
  • Sets the color of the thumb for the specified state.

    In general, if a property is not specified for a state, the default is to use the @c UIControlStateNormal value. If the @c UIControlStateNormal value is not set, then the property defaults to a default value. Therefore, at a minimum, you should set the value for the normal state.

    Declaration

    Objective-C

    - (void)setThumbColor:(nullable UIColor *)thumbColor
                 forState:(UIControlState)state;

    Parameters

    thumbColor

    The color of the thumb (cursor).

    state

    The state of the slider.

  • Returns the thumb color associated with the specified state.

    @params state The state that uses the thumb color. @returns The thumb color for the specified state. If no color has been set for the specific state, this method returns the color associated with the @c UIControlStateNormal state.

    Declaration

    Objective-C

    - (nullable UIColor *)thumbColorForState:(UIControlState)state;
  • Sets the color of the filled track area for the specified state.

    In general, if a property is not specified for a state, the default is to use the @c UIControlStateNormal value. If the @c UIControlStateNormal value is not set, then the property defaults to a default value. Therefore, at a minimum, you should set the value for the normal state.

    Declaration

    Objective-C

    - (void)setTrackFillColor:(nullable UIColor *)fillColor
                     forState:(UIControlState)state;

    Parameters

    fillColor

    The color of the filled track.

    state

    The state of the slider.

  • Returns the track fill color associated with the specified state.

    @params state The state that uses the track fill color. @returns The track fill color for the specified state. If no color has been set for the specific state, this method returns the color associated with the @c UIControlStateNormal state.

    Declaration

    Objective-C

    - (nullable UIColor *)trackFillColorForState:(UIControlState)state;
  • Sets the color of the background (unfilled) track for the specified state.

    In general, if a property is not specified for a state, the default is to use the @c UIControlStateNormal value. If the @c UIControlStateNormal value is not set, then the property defaults to a default value. Therefore, at a minimum, you should set the value for the normal state.

    Declaration

    Objective-C

    - (void)setTrackBackgroundColor:(nullable UIColor *)backgroundColor
                           forState:(UIControlState)state;

    Parameters

    backgroundColor

    The color of the inactive track.

    state

    The state of the slider.

  • Returns the track background color associated with the specified state.

    @params state The state that uses the track background color. @returns The track background color for the specified state. If no color has been set for the specific state, this method returns the color associated with the @c UIControlStateNormal state.

    Declaration

    Objective-C

    - (nullable UIColor *)trackBackgroundColorForState:(UIControlState)state;
  • Sets the color of the ticks within the filled track to use for the specified state.

    In general, if a property is not specified for a state, the default is to use the @c UIControlStateNormal value. If the @c UIControlStateNormal value is not set, then the property defaults to a default value. Therefore, at a minimum, you should set the value for the normal state.

    Declaration

    Objective-C

    - (void)setFilledTrackTickColor:(nullable UIColor *)tickColor
                           forState:(UIControlState)state;

    Parameters

    tickColor

    The color of the tick marks within the filled track.

    state

    The state of the slider.

  • Returns the tick color for the filled track portion associated with the specified state.

    @params state The state that uses the filled-track tick color. @returns The filled-track tick color for the specified state. If no color has been set for the specific state, this method returns the color associated with the @c UIControlStateNormal state.

    Declaration

    Objective-C

    - (nullable UIColor *)filledTrackTickColorForState:(UIControlState)state;
  • Sets the color of the ticks for the background (unfilled) track to use for the specified state.

    In general, if a property is not specified for a state, the default is to use the @c UIControlStateNormal value. If the @c UIControlStateNormal value is not set, then the property defaults to a default value. Therefore, at a minimum, you should set the value for the normal state.

    Declaration

    Objective-C

    - (void)setBackgroundTrackTickColor:(nullable UIColor *)tickColor
                               forState:(UIControlState)state;

    Parameters

    tickColor

    The color of the tick marks outside the filled track.

    state

    The state of the slider.

  • Returns the tick color for the background (unfilled) track portion associated with the specified state.

    @params state The state that uses the background-track tick color. @returns The background-track tick color for the specified state. If no color has been set for the specific state, this method returns the color associated with the @c UIControlStateNormal state.

    Declaration

    Objective-C

    - (nullable UIColor *)backgroundTrackTickColorForState:(UIControlState)state;
  • The color of the Ink ripple.

    Defaults to transparent blue.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *inkColor;
  • The radius of the cursor (thumb).

    Default value is 6 points.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat thumbRadius;
  • The elevation of the cursor (thumb).

    Default value is MDCElevationNone.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCShadowElevation thumbElevation;
  • The number of discrete values that the slider can take.

    If greater than or equal to 2, the thumb will snap to the nearest discrete value when the user lifts their finger or taps. The discrete values are evenly spaced between the @c minimumValue and @c maximumValue. If 0 or 1, the slider’s value will not change when the user releases the thumb.

    The default value is zero.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger numberOfDiscreteValues;
  • The value of the slider.

    To animate from the current value to the new value, instead use - see: setValue:animated:. The value will be clamped between @c minimumValue and @c maximumValue. Setting the value will not send an action message.

    The default value of this property is 0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat value;
  • Set the value of the slider, allowing you to animate the change visually.

    If animated is YES, the thumb is animated into its new position. Setting the value does not result in an action message being sent.

    Declaration

    Objective-C

    - (void)setValue:(CGFloat)value animated:(BOOL)animated;

    Parameters

    value

    The value to set the slider to.

    animated

    If YES, the thumb will animate to its new position.

  • The minimum value of the slider.

    If you change the value of this property and the @c value of the receiver is below the new minimum, the current value will be adjusted to match the new minimum value. If you change the value of this property and @c maximumValue of the receiver is below the new minimum, the @c maximumValue will also be set to this new minimum value.

    The default value of this property is 0.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat minimumValue;
  • The maximum value of the slider.

    If you change the value of this property and the @c value of the receiver is above the new maximum, the current value will be adjusted to match the new maximum value. If you change the value of this property and @c minimumValue of the receiver is above the new maximum, the @c minimumValue will also be set to this new maximum value.

    The default value of this property is 1.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat maximumValue;
  • Indicates whether changes in the slider’s value generate continuous update events.

    If YES, the slider sends update events continuously to the associated target’s action method. If NO, the slider only sends an action event when the user releases the slider’s thumb control to set the final value.

    The default value of this property is YES.

    Declaration

    Objective-C

    @property (getter=isContinuous, assign, readwrite, nonatomic) BOOL continuous;
  • The value from which the filled part of the track is anchored. If set to a value between minimumValue and maximumValue, then the filled/colored part of the track extends from the trackAnchorValue to the thumb. Values beyond the minimum/maximum values are effectively capped.

    The default value is -CGFLOAT_MAX, so the filled part of the track extends from the minimum value to the thumb.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat filledTrackAnchorValue;
  • Whether or not to show the numeric value label when dragging a discrete slider. If YES, consider implementing MDCSliderDelegate’s @c -slider:displayedStringForValue: method to customize the string displayed for each discrete value.

    Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL shouldDisplayDiscreteValueLabel;
  • The color of the discrete value label’s text.

    Resets to the default color.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *valueLabelTextColor;
  • The color of the discrete value label’s background.

    Resets to the default color.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *valueLabelBackgroundColor;
  • Whether or not the thumb view should be a hollow circle when at the minimum value. For sliders where the minimum value indicates that the associated property is off (for example a volume slider where a value of 0 = muted), this should be set to YES. In cases where this doesn’t make sense (for instance a scrubber of an audio or video file), this should be set to NO.

    Defaults to YES.

    Declaration

    Objective-C

    @property (getter=isThumbHollowAtStart, assign, readwrite, nonatomic)
        BOOL thumbHollowAtStart;
  • The color of the cursor (thumb) and track while the slider is disabled.

    Default color is gray.

    Note

    This API is planned for deprecation. Use @c setThumbColor:forState: and @c setTrackBackgroundColor:forState: instead.

    Note

    Has no effect if @c statefulAPIEnabled is @c YES.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *disabledColor;
  • The color of the cursor (thumb) and filled in portion of the track (left side).

    Default color is blue.

    Note

    This API is planned for deprecation. Use @c inkColor, @c setThumbColor:forState:, and @c setTrackFillColor:forState: instead.

    Note

    Has no effect if @c statefulAPIEnabled is @c YES.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *color;
  • The color of the unfilled track that the cursor moves along (right side).

    Default color is gray.

    Note

    This API is planned for deprecation. Use @c setTrackBackgroundColor:forState: instead.

    Note

    Has no effect if @c statefulAPIEnabled is @c YES.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *trackBackgroundColor;