You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Image(.colombia).resizable().scaledToFit().containerRelativeFrame(.horizontal){ size, axis in
size *0.8}
How ScrollView lets us work with scrolling data
import SwiftUI
structCustomText:View{lettext:Stringvarbody:someView{Text(text)}init(text:String){print("Creating a CustomText")self.text = text
}}structContentView:View{varbody:someView{ScrollView{LazyVStack(spacing:10){ForEach(0..<100){CustomText( text:"Item \($0)").font(.title)}}.frame(maxWidth:.infinity)}}}
Pushing new views onto the stack using NavigationLink
import SwiftUI
structContentView:View{varbody:someView{NavigationStack{List(0..<10){ row inNavigationLink("Row \(row)"){Text("Detail \(row)")}}NavigationLink{Text("Detail View")} label:{VStack{Text("This is a label")Text("So is this")Image(systemName:"face.smiling")}}.navigationTitle("SwiftUI")}}}
Working with hierarchical Codable data
import SwiftUI
structUser:Codable{letname:Stringletaddress:Address}structAddress:Codable{letstreet:Stringletcity:String}structContentView:View{varbody:someView{Button("Decode JSON"){letinput=""" {"name": "Taylor Swift","address": {"street": "555, Taylor Swift Avenue","city": "Nashville" } }"""letdata=Data(input.utf8)iflet user =try?JSONDecoder().decode(User.self, from: data){print(user.address.street)}}}}