๐ŸŽ›๏ธ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`

Last updated