2

我想显示一个多色复杂图标,类似于默认计时器应用程序图标:

在此处输入图像描述

这是我以多色显示图标的代码:

CLKComplicationTemplateModularSmallStackImage* template=[[CLKComplicationTemplateModularSmallStackImage alloc]init];

template.line1ImageProvider=[CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"Complication/Modular"] 
    twoPieceImageBackground:[UIImage imageNamed:@"ComplicationForeground/Modular"] 
    twoPieceImageForeground:[UIImage imageNamed:@"ComplicationBackgroud/Modular"]];

entry = [CLKComplicationTimelineEntry entryWithDate:[NSDate date]
                                           complicationTemplate:template];

两幅图像都有清晰的背景。如何用 whiteColor 为中心图像着色,用另一种颜色为外部图像着色?

4

1 回答 1

5

使用该tintColor属性指定两片图像背景的色调颜色。

例如,如果您希望两件式图像背景颜色为绿色,您可以指定:

template.line1ImageProvider.tintColor = [UIColor greenColor]; // Objective-C

template.line1ImageProvider?.tintColor = UIColor.greenColor() // Swift

有关详细信息,请参阅 CLKImageProvider 类参考

两件式图像仅在多色环境中显示,并且在这些环境中优先于一件式图像。两片图像由叠加在背景图像之上的前景图像组成。两个图像都是模板图像。ClockKit 将 tintColor 属性中的颜色应用于背景图像,如果未指定自定义颜色,则回退到基础模板中的颜色或白色。ClockKit 总是将白色应用于前景图像。在单色环境中不使用两片图像。

于 2016-01-29T01:33:01.793 回答