简体   繁体   English

tintedImageProvider 在图形复杂功能中不提供色调颜色

[英]tintedImageProvider does not provide tint color in Graphic Complication

I am trying to create Graphic Complications for my Apple Watch app (namely Graphic Circular) and I've run into some problems.我正在尝试为我的 Apple Watch 应用程序(即图形循环)创建图形复杂功能,但遇到了一些问题。 To support both multicolor and tinted watch faces, I use the following code to provide image for my complication:为了同时支持多色和有色表盘,我使用以下代码为我的复杂功能提供图像:

    let graphicCircularTemplate = CLKComplicationTemplateGraphicCircularImage()
    if let tintedImage = UIImage(named: "GraphicCircular"), let fullColorImage = UIImage(named: "GraphicCircularOrange") {
        let tintedImageProvider = CLKImageProvider(onePieceImage: tintedImage)
        var imageProvider = CLKFullColorImageProvider()
        if #available(watchOSApplicationExtension 6.0, *) {
            imageProvider = CLKFullColorImageProvider(fullColorImage: fullColorImage, tintedImageProvider: tintedImageProvider)
        } else {
            imageProvider = CLKFullColorImageProvider(fullColorImage: fullColorImage)
        }
        graphicCircularTemplate.imageProvider = imageProvider
    }

Now my fullColorImage is following: fullColorImage现在我的fullColorImage如下: fullColorImage

Whereas the tinted image of same size is rendered as Template image: tintedImage而相同大小的着色图像呈现为模板图像: tintedImage

In multicolor Infograph watch face the full color image looks as expected: multicolor在多色 Infograph 表盘中,全彩色图像看起来如预期:多色

But when I change watch face to a selected tint, my tinted image renders as pure white, and the system tint color does not get applied to it: tint color但是当我将表盘更改为选定的色调时,我的着色图像呈现为纯白色,并且系统色调颜色不会应用于它:色调颜色

So my question is what am I missing and why does my tintedImageProvider not provide any tint?所以我的问题是我错过了什么,为什么我的 tintedImageProvider 不提供任何色调?

Besides, I've noticed that system complications of type Graphic Circular seem to have a slightly grey background which sets them apart in dark watch face environment.此外,我注意到 Graphic Circular 类型的系统并发症似乎有一个略带灰色的背景,这使它们在黑暗的表盘环境中与众不同。 I have hardcoded same background color into full color image, but when face switches to tint mode - my complication's background goes completely black.我已将相同的背景颜色硬编码为全彩色图像,但是当面部切换到色调模式时 - 我的并发症背景完全变黑。 Any ideas on how to achieve this grey background effect?关于如何实现这种灰色背景效果的任何想法?

Well, solution came after reiterating through documentation several times - decided to post an answer in case someone else finds this solution as non-obvious as I did:好吧,解决方案是在多次重复文档之后出现的 - 决定发布答案,以防其他人发现此解决方案与我一样不明显:

In Graphic complications that support multicolor watch faces with full-color complication images system tint is only applied to twoPieceImageForeground parameter of tintedImageProvider .在图形并发症支持多色表盘与全彩色图像的复杂系统色调仅适用于twoPieceImageForeground的参数tintedImageProvider Simply providing a template onePieceImage doesn't do the trick.简单地提供一个模板onePieceImage并不能解决问题。

Creating a two piece image also resolves the second part of my question regarding grey background for image in Graphic Circular complication.创建两件式图像还解决了我关于图形圆形复杂功能中图像的灰色背景问题的第二部分。 To solve this, I've created a plain rectangle image of required complication size, set its background color to black and alpha to 11%.为了解决这个问题,我创建了一个所需复杂大小的普通矩形图像,将其背景颜色设置为黑色,将 alpha 设置为 11%。 Passing this image as twoPieceImageBackground parameter to tintedImageProvider creates the needed grey-background effect upon desaturation.将此图像作为twoPieceImageBackground参数传递给tintedImageProvider会在去饱和时创建所需的灰色背景效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM