Mobile App Development 2021W Lecture 16
Code
//
// ContentView.swift
// Shared
//
// Created by Anil Somayaji on 2021-03-15.
//
import SwiftUI
struct ContentView: View {
@State var count = 0
var body: some View {
VStack{
Button("Tap here!", action: onTapped)
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
Text("You have tapped \(count) times.")
.padding()
}
}
func onTapped() {
count = count + 1
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}