๐๏ธSlider
// slider without label
Slider(value: $width, in: 0...500, step: 10)
// slider with min/max label
Slider(
value: $speed,
in : 0...100,
step : 5
) { Text("Speed") } // slider label
minimumValueLabel: { Text("0") }
maximumValueLabel: { Text("100") }
onEditingChanged : { editing in isEditing = editing }
// โญ๏ธ `in` ๅๆธ้ ่จญๅผ็บ 0...1๏ผๅฏ็็ฅใ
Slider(value: $scale)
.accentColor(.orange) // โญ๏ธ ่จญๅฎ slider ็้ก่ฒ
Slider(
value: $age,
in : 18...80,
step : 1, // โญ๏ธ ่จญๅฎใ้่ทใ
// โญ๏ธ ้กฏ็คบๆๅฐๅผใๆๅคงๅผ
// โ ๏ธ ้ๅ
ฉๅ value label ๅฆๆไธๆฏๅๅๅฅ๏ผไผผไนๆ็ข็้ฏ่ชคโ
minimumValueLabel: Text("18"),
maximumValueLabel: Text("80")
){ EmptyView() } // โญ๏ธ ไธไฝฟ็จ `label`
TestIdealSizeView - to control parent's offered size.
SlidersForSize - control width/height.
Slider ๆฅๅๅๅฅ Binding<BinaryFloatingPoint> ็ๅๆธใ
Float๏ผDouble๏ผCGFloat ้ฝ้ตๅพ BinaryFloatingPointใ
in ๅๆธ็้ ่จญๅผ็บ 0โฆ1๏ผๅฏ็็ฅใ
ๅฐๆธไฝๆธๅฏ็จ
Text("\(scale, specifier: "%.2f")" )
็ๆ ผๅผ่จญๅฎใ
SwiftUI โฉ Views and Controls โฉ Slider
Last updated