Listen mit transparentem Hintergrund

  • Listen mit transparentem Hintergrund

    Hallo,

    ich habe diese Liste hier und möchte, dass der weiße Listenhintergrund verschwindet, da die BackgroudView ein Bild lädt und die einzelnen Listenelemente mit diesem leicht durchscheinenden .regularMaterial Look darüber schweben sollen. Momentan funktioniert das aber leider nicht ...

    Quellcode

    1. import SwiftUI
    2. import WeatherKit
    3. struct CitiesListView: View {
    4. // use dismiss to remove a view from a NavigationStack
    5. @Environment(\.dismiss) private var dismiss
    6. let currentLocation: City?
    7. @Binding var selectedCity: City?
    8. var body: some View {
    9. NavigationStack {
    10. List {
    11. Group {
    12. if let currentLocation {
    13. CityRowView(city: currentLocation)
    14. .onTapGesture {
    15. selectedCity = currentLocation
    16. dismiss()
    17. }
    18. }
    19. ForEach(City.cities) { city in
    20. CityRowView(city: city)
    21. .onTapGesture {
    22. selectedCity = city
    23. dismiss()
    24. }
    25. }
    26. }
    27. .frame(maxWidth: 0.95 * UIScreen.main.bounds.width)
    28. .padding(.vertical, 5)
    29. .background(.regularMaterial)
    30. .clipShape(.rect(cornerRadius: 20))
    31. }
    32. .listStyle(.plain)
    33. .listRowBackground(Color.clear)
    34. .navigationTitle(Text("My Cities").foregroundStyle(.white))
    35. .navigationBarTitleDisplayMode(.inline)
    36. .background {
    37. BackgroundView()
    38. }
    39. }
    40. }
    41. }
    42. #Preview {
    43. CitiesListView(currentLocation: City.mockCurrent, selectedCity: .constant(nil))
    44. .environment(LocationManager())
    45. }
    Alles anzeigen
    der Modifier .foregroundStyle(.white) von dem navigationTitle wird übrigens auch ignoriert ...