UISlider: setMinimumTrackImage() method
The setMinimumTrackImage() method sets the image of the track to the left of the thumb for one or more of the slider's states, replacing the system-drawn appearance.
Syntax
setMinimumTrackImage(image, { forState })Parameters
image
UIImage, or null. null removes the image for these states.
options.forState
An array of state names, required. Usually ['normal']: states that haven't been set separately use the normal image. The state names are 'normal', 'highlighted' (finger pressing), 'disabled', 'selected', and 'focused'; see States.
Return value
None (undefined).
Exceptions
TypeError
forStatenot passed:setMinimumTrackImage needs { forState }.forStatecontains an unrecognized state name:forState has no value "pressed"; expected one of: normal / highlighted / disabled / selected / focused.imageis neither aUIImagenornull:setMinimumTrackImage needs a UIImage or null.
Examples
js
const slider = new UISlider();
const dot = UIImage.systemImageNamed('circle.fill');
slider.setMinimumTrackImage(dot, { forState: ['normal'] });
console.log(slider.minimumTrackImageForState('normal') === dot);
console.log(slider.minimumTrackImageForState('highlighted') === dot);Effect
- Prints
truetwice:highlightedhasn't been set separately, so it uses thenormalimage. - The left track is displayed as this image. Not verified in the simulator.
Corresponding iOS API
-[UISlider setMinimumTrackImage:forState:]. The state is a bitmask in ObjC; here it is written as an array.
See also
minimumTrackImageForState(): reading the image for a statecurrentMinimumTrackImage: the image used for the current statesetThumbImage(),setMaximumTrackImage()