๐๏ธSlidersForSize
swiftโฉ custom โฉ control โฉ SliderForSize

// 2022.02.15 (*)
// 2022.02.17 (+) struct: SliderWithSubtitle
// (f) bug : step can be < 1
import SwiftUI
// โโโโโโโโโโโโโโโโโโโโโโโโ
// โ SlidersForSize โ
// โโโโโโโโโโโโโโโโโโโโโโโโ
/// ๐ sliders to control width/height
/// ```
/// SlidersForSize($size)
/// ```
struct SlidersForSize: View {
// โญ๏ธ Binding variable
@Binding var size: CGSize
var body: some View {
VStack(spacing: 20) {
// ๐ Slider: control offered width
SliderWithSubtitle(
value : $size.width,
subtitle: "width"
)
// ๐ Slider: control offered height
SliderWithSubtitle(
value : $size.height,
range : 100...300,
subtitle: "height",
tint : .blue
)
}
}
}
// convenience init
extension SlidersForSize {
/// convenience init.
/// ```
/// SlidersForSize($size)
/// ```
init(_ size: Binding<CGSize>) {
// โญ๏ธ ๆณจๆ๏ผไธๆฏ `self.size = size` โ๏ธโ๏ธโ๏ธ
self._size = size
}
}
// โโโโโโโโโโโโโโโโโโ
// โ Previews โ
// โโโโโโโโโโโโโโโโโโ
struct SlidersForSize_Previews: PreviewProvider {
static var previews: some View {
SlidersForSize(size: .constant(.init(300,200)))
}
}
History
2022.02.17
Last updated
Was this helpful?