SwiftUI - Switch Control Example

   Example of using a Picker in SwiftUI - Popup with the picker data



import SwiftUI


struct ContentView : View {

    @State private var isShowAds = false

    var body: some View {

        Form {

            Section {

                Toggle(isOn: $isShowAds) {

                    Text("Yes Show Ads")

                }


                if isShowAds {

                    Text("Show Ad")

                }

            }

        }

    }

}

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}



Output: 




SwiftUI - Switch Control Example SwiftUI - Switch Control Example Reviewed by KIRIT MODI on 00:33:00 Rating: 5

No comments:

Powered by Blogger.