【问题标题】:TintColor does not apply to my Complication when using rendering Mode "Template" (CLKComplicationTemplateGraphicCircularClosedGaugeImage)使用渲染模式“模板”(CLKComplicationTemplateGraphicCircularClosedGaugeImage)时,TintColor 不适用于我的复杂功能
【发布时间】:2020-09-07 11:43:36
【问题描述】:

我目前正在尝试实施 CLKComplicationTemplateGraphicCircularClosedGaugeImage 但由于某种原因,我的图标一直变蓝。

当我更改 WatchFace 的 tintColor 时,一切似乎都以正确的方式着色。但是,当我在 WatchFace 上禁用着色时,我的图像会因某种原因变成蓝色。

我在资产目录中启用了渲染模式:alwaystemplate,因为我的图像在原始版本中只是黑色,而我在应用程序的其他部分对其进行了着色。

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

我尝试在模板上应用 tintColor,并且在将图像传递给 ImageProvider 之前,我还尝试将 tintColor 直接应用到图像。两个想法都没有产生预期的输出。

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

使用 alwaysTemplate 作为渲染模式时,如何设置默认色调?

【问题讨论】:

    标签: watchkit apple-watch-complication clockkit


    【解决方案1】:

    我自己找到了解决方案。 我现在将图像着色为白色并将其重新渲染为原始图像。

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

    【讨论】:

    • 我很想知道为什么会这样。感谢分享这个解决方案!
    猜你喜欢
    • 1970-01-01
    • 2020-03-09
    • 1970-01-01
    • 2018-06-09
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    相关资源
    最近更新 更多