Search code examples
swiftswiftuiwatchkitapple-watchwatchos

Display an UIImage in SwitfUI is dark - Apple Watch


I do not understand why the car systemName image does not appear on Apple Watch Simulator. (it is black)

import SwiftUI
struct ContentView: View {
    var body: some View {
        Image(uiImage: UIImage(systemName: "car")!)
    }
}

struct preview : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Click here to see how it looks (the screen is completely black, like if nothing was added to the view)


Solution

  • I suppose it should be

    enter image description here

    struct ContentView: View {
        var body: some View {
            Image(systemName: "car") // < Native SwiftUI
        }
    }
    

    or... if you so like UIImage, the same result with

    Image(uiImage: UIImage(systemName: "car")!).colorInvert()