Skip to content

UISlider() constructor ​

The UISlider() constructor creates a slider.

Syntax ​

new UISlider()

Parameters ​

None.

Return value ​

A new UISlider. Its properties have their default values:

PropertyDefault
value0
minimumValue0
maximumValue1
isContinuoustrue
sliderStyle'default'
The three color propertiesnull
The two end images and the three per-state imagesnull

A new slider is 0 wide and not visible on screen. Its height is determined by the system; measured on iOS 27.2 it is 34 pt. When you add it to a page, give it a width: write frame, add a width constraint, or put it in a vertical UIStackView that stretches it.

Exceptions ​

None.

It can't be subclassed: class MySlider extends UISlider {} throws TypeError at new MySlider(); see Native classes.

Examples ​

js
const slider = new UISlider();
slider.frame = new CGRect(16, 100, 300, 34);
console.log(slider.value, slider.minimumValue, slider.maximumValue);

Result

  • Prints 0 0 1.
  • You get a slider 300 pt wide with the thumb at the far left. How it looks on screen is not verified in the simulator.

Corresponding iOS API ​

[[UISlider alloc] init].

See also ​