In an Apple CarPlay CPGridTemplate
with several buttons, the buttons from a system UIImage
are tinted cyan by the system, while the buttons from a custom SVG stay black. All combinations of .withRenderingMode(...)
, .withTintColor(.cyan)
to get the custom UIImage displayed in cyan color are to no avail.
I realized when I export the cart.fill symbol from Apple SF-Symbols as an SVG and import it in Xcode as a custom SVG asset, it stays back as well.
What is the reason? How to get the custom SVG tinted by CarPlay same as the system symbols?
// This Button is displayed in CYAN
let cyanButton = CPGridButton(titleVariants: [...],
image: UIImage(systemName: "cart.fill")!)
{ button in ... }
// This Button is displayed in BLACK
let blackButton = CPGridButton(titleVariants: [...],
image: UIImage(named: "playground.fill")!)
{ button in ... }
let gridTemplate = CPGridTemplate(title: ...), gridButtons: [cyanButton, blackButton])
Custom SVG UIImage in CPGridTemplate stay black
I tried:
UIImage(named: "playground.fill")!.withRenderingMode(.alwaysTemplate)
UIImage(named: "playground.fill")!.withRenderingMode(.alwaysOriginal)
UIImage(named: "playground.fill")!.withRenderingMode(.alwaysTemplate).withTintColor(.cyan)
UIImage(named: "playground.fill")!.withRenderingMode(.alwaysOriginal).withTintColor(.cyan)
Any idea is highly welcome.