Skip to content

Instantly share code, notes, and snippets.

@kiritmodi2702
Created September 18, 2019 06:01
Show Gist options
  • Save kiritmodi2702/f7b57a4affc819a23bec5fa8c963aa37 to your computer and use it in GitHub Desktop.
Save kiritmodi2702/f7b57a4affc819a23bec5fa8c963aa37 to your computer and use it in GitHub Desktop.
SwiftUI - Alert Example.
//
// 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