/AlertWithTextField

SwiftUI Custom Alert View with TextField

Primary LanguageSwift

Alert With TextField

OeverView

image

image-20200120170710458

image

Usage

@State var shown = false
    @State var text = ""
    var body: some View {
        ZStack{
            //main page design ...
            Button(action: {
                self.text = ""
                self.shown.toggle()
            }){
                Text("button")
                
            }
                
            if self.shown{
                alertView(text: self.$text, shown: self.$shown) //alertView is Custom Alert
            }
            else{
                alertView(text: self.$text, shown: self.$shown).hidden()
            }
            
        }
    }