Advertisement
dartmeadow

add a system image to the string or custom image?

Sep 13th, 2021
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.70 KB | None | 0 0
  1. import SwiftUI
  2.  
  3. struct MyApp: App {
  4.   var body: some Scene {
  5.         WindowGroup {
  6.       HomeView()
  7.         }
  8.   }
  9. }
  10. struct HomeView: View {
  11.    
  12.     @State var strings: [String] = ["\(Image(systemName: "sun.max.fill"))DART Meadow", "B", "C"]
  13.   @State var selection: String?
  14.   var body: some View {
  15.       NavigationView {
  16.       List(selection: $selection) {
  17.         ForEach(strings, id: \.self) { string in
  18.           Text(string)
  19.           }
  20.         }
  21.             .listStyle(SidebarListStyle())
  22.         VStack {
  23.         Spacer()
  24.         Text(selection ?? "<none>")
  25.           .frame(idealWidth: 100, maxWidth: .infinity, alignment: .center)
  26.              Spacer()
  27.             }
  28.     }
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement