Search code examples
watchkitapple-watch-complicationclockkit

TintColor does not apply to my Complication when using rendering Mode "Template" (CLKComplicationTemplateGraphicCircularClosedGaugeImage)


I am currently trying to implement a CLKComplicationTemplateGraphicCircularClosedGaugeImage but for some reason my icon keeps getting tinted blue.

When I change the tintColor of the WatchFace everything seems to be tinted the right way. But when I disable tinting on the WatchFace my Image will be colored blue for some reason.

I enabled the rendering Mode: alwaystemplate inside the asset catalog because my image is just black in the original version and I tint it in other parts of my app.

let gaugeProvider = CLKSimpleGaugeProvider(style: .fill, gaugeColor: color, fillFraction: progress)
let template = CLKComplicationTemplateGraphicCircularClosedGaugeImage(gaugeProvider: gaugeProvider, imageProvider: CLKFullColorImageProvider(fullColorImage: image))

I tried to apply a tintColor on the template and I also tried to apply a tintColor direclty to the image before passing it to the ImageProvider. Both Ideas doesnt result in the expected output.

let gaugeProvider = CLKSimpleGaugeProvider(style: .fill, gaugeColor: color, fillFraction: progress)
let imageProvider = CLKFullColorImageProvider(fullColorImage: image)
let template = CLKComplicationTemplateGraphicCircularClosedGaugeImage(gaugeProvider: gaugeProvider, imageProvider: imageProvider)
template.tintColor = .white // this has no effect

How can I set a default tint color when using alwaysTemplate as the rendering mode?


Solution

  • I found a Solution by myself. I am now tinting the Image white and also rerendering it as a originalImage.

    let imageProvider = CLKFullColorImageProvider(fullColorImage: image.withTintColor(.white, renderingMode: .alwaysTemplate).withRenderingMode(.alwaysOriginal))