SwiftUI - Button Example With Action.
This tutorial to display Button in SwiftUI. we are use the UIButton in the Swift. SwiftUI introduce a Button Class to define Button. Here we are study how to define Button and what's its properties. first you create SwiftUI Project.
You are study to "UIButton Programmatically in Swift 5", Now this tutorial for Button in SwiftUI.
Before the tutorial you will check "Text In SwiftUI", because In this tutorial we are use also SwiftUI Text.
Full Code of Button SwiftUI:
Output:
// Created by Kirit Modi.
// Copyright © 2019 iOSDevCenters. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@State private var showiOSDetail = false
var body: some View {
VStack {
Button(action: {
self.showiOSDetail.toggle()
}) {
Text("iOS Blog")
.foregroundColor(Color.white)
}
.padding()
.background(Color.blue)
if showiOSDetail {
Text("You are click on iOsDevCenters ")
.font(.headline)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Output:
SwiftUI - Button Example With Action.
Reviewed by KIRIT MODI
on
21:02:00
Rating:
No comments: