In my SwiftUI View I've an Image that I've loaded from assets. I've set the foregroundColor to accentColor, which I've also set in asset as my custom AccentColor which is to be used throughout the app.
Asset:
ContentView body:
var body: some View {
Image("MyImageName")
.resizable()
.renderingMode(.template)
.foregroundColor(.accentColor)
.frame(width: 32, height: 32, alignment: .center)
}
The preview and the simulator show the image in the right foregroundColor. But, while running on a physical device the foregroundColor somehow remain the default blue accentColor of the phone.
Preview:
Simulator:
Real Device:
Why does this happen? And how do I make sure the AssentColor work across devices no matter the iOS version without modifying any settings on the iPhone? Debug details: The device iOS version is iOS 13.5.1 and Xcode 12.0.1.
