SwiftUI 第一章

2022-09-30  本文已影响0人  不要虚度美好的时光
Snip20221001_29.png Snip20221001_33.png Snip20221001_40.png ![Snip20221003_44.png](https://img.haomeiwen.com/i1696356/967d57fe07f5efb8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
struct ContentView: View {
    @State private var alertIsVisiable: Bool = false
    @State private var sliderValue: Double = 50.0
    var body: some View {
        VStack {
            Text("🎣🎣🎣🎣\n让鱼竿尽可能接近鱼")
                .bold()
                .kerning(4.0)
                .multilineTextAlignment(.center)
                .lineSpacing(4.0)
                .font(.footnote)
                .lineSpacing(5)
            
            
            Text("89米")
                .kerning(-1.0)
                .font(.largeTitle)
                .fontWeight(.black)
            HStack{
                Text("1米")
                    .bold()
                Slider(value: $sliderValue, in: 1.0...100.0)
                Text("100米")
                    .bold()
            }
            
            Button {
                alertIsVisiable = true
                print("点击了 点我啊")
            } label: {
                
                Text("点我啊")
            }
            .alert(isPresented: $alertIsVisiable) {
                return Alert(title: Text("你好呀!"), message: Text("滑块的值是:\(Int(sliderValue.rounded()))"), dismissButton: .default(Text("真棒👍")))
            }
            

        }
    }
}

参考资料1
参考资料2
参考资料3

上一篇下一篇

猜你喜欢

热点阅读