Created
September 18, 2019 06:01
-
-
Save kiritmodi2702/f7b57a4affc819a23bec5fa8c963aa37 to your computer and use it in GitHub Desktop.
SwiftUI - Alert Example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// ImageSwiftUI | |
// | |
// Created by Kirit Modi on 17/09/19. | |
// Copyright © 2019 iOSDevCenters. All rights reserved. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@State private var isAlert = false | |
var body: some View { | |
Button(action: { | |
self.isAlert = true | |
}) { | |
Text("Click Alert") | |
.foregroundColor(Color.white) | |
} | |
.padding() | |
.background(Color.blue) | |
.alert(isPresented: $isAlert) { () -> Alert in | |
Alert(title: Text("iOSDevCenters"), message: Text("This Tutorial for SwiftUI Alert."), primaryButton: .default(Text("Okay"), action: { | |
print("Okay Click") | |
}), secondaryButton: .default(Text("Dismiss"))) | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment