Home > AI > Uncategorized

A toggle button

This the code

//
//  ContentView.swift
//  navigation
//
//  Created by dph on 2020/10/13.
//  Copyright © 2020 sj. All rights reserved.
//

import SwiftUI
import Speech


struct ContentView: View {
    @State var showDetails: Bool
 
    var body: some View {
        VStack {
            Button(action: {
                self.showDetails.toggle()
            }) {
                Text("Voice")
            }

            if showDetails {
            Text("You should follow me on Twitter: @twostraws")
            .font(.largeTitle)
            }
        }
    }
}



struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(showDetails: false)
    }
}

Here is the result

Related posts:
Relevant tags:

Leave a Reply