article

Monday, May 17, 2021

SwiftUI Popover

SwiftUI Popover
 
//
//  ContentView.swift
//  Testapp
//
//  Created by Cairocoders
//

import SwiftUI

struct ContentView: View {
    
    @State var isPopoverPresented = false

    var body: some View {

        Button(action: {
            self.isPopoverPresented = true
        }) {
            Text("Show Popover")
        }

        .popover(isPresented: $isPopoverPresented) {
            Text("Popover is Presented")
                .font(.largeTitle)
                .frame(width: 500, height: 500)
        }
        
    }
}

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

Related Post