MDCSliderDelegate

@protocol MDCSliderDelegate <NSObject>

MDCSlider delegate which allows setting custom behavior.

  • Called when the user taps on the MDCSlider.

    If not implemented, the MDCSlider will always be allowed to jump to any value.

    Declaration

    Objective-C

    - (BOOL)slider:(nonnull MDCSlider *)slider shouldJumpToValue:(CGFloat)value;
  • For discrete sliders, called when the slider is determining the string label to display for a given discrete value.

    If not implemented, or if no slider delegate is specified, the slider defaults to displaying the value rounded to the closest relevant digit. For instance, 0.50000 would become 0.5

    Override this to provide custom behavior, for instance if your slider deals in percentages, the above example could become 50%

    Declaration

    Objective-C

    - (nonnull NSString *)slider:(nonnull MDCSlider *)slider
         displayedStringForValue:(CGFloat)value;

    Parameters

    slider

    The MDCSlider sender.

    value

    The value whose label needs to be calculated.

  • Used to determine what string value should be used as the accessibility string for a given value.

    If not implemented, or if no slider delegate is specified, the slider defaults to how filled the slider is, as a percentage. Override this method to provide custom behavior, and when implementing, you may want to also implement @c -slider:displayedStringForValue: to ensure consistency between the displayed value and the accessibility label.

    Declaration

    Objective-C

    - (nonnull NSString *)slider:(nonnull MDCSlider *)slider
        accessibilityLabelForValue:(CGFloat)value;

    Parameters

    slider

    The MDCSlider sender.

    value

    The value whose accessibility label needs to be calculated.