I just completed day 20 of 100 days of SwiftUi. Today, I learnt about the HStack, VStack, Button Alert views
The VStack view is used to stack views vertically while the HStack view is used to stack views horizontally. For example, VStack and HStack in SwiftUI can be written like this
var body: some View {
VStack {
Text("Hello World")
Text("This is inside a stack")
}
}
var body: some View {
HStack {
Text("Hello World")
Text("This is inside a stack")
}
}
The button view is used to create a button. For example, Button in SwiftUI can be written like so
var body: some View {
Button("Tap me!") {
print("Button was tapped")
}
}
The code above creates a button view with the text "Tap me". It also accepts a closure that prints the text "Button was tapped" anytime the button was tapped.
If you are interested in taking the challenge, you can find it at https://www.hackingwithswift.com/100/swiftui
See you tomorrow ;)
Top comments (0)