双片影像并发症
TwoPieceImage Complication
我想显示一个多色的 Complication 图标,类似于默认计时器应用程序图标:
这是我用多色显示图标的代码:
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];
两幅图背景清晰。如何用白色为中心图像着色,用另一种颜色为外部图像着色?
使用 tintColor
属性 指定两件式图像背景的色调。
例如,如果您希望两张图片的背景颜色为绿色,您可以指定:
template.line1ImageProvider.tintColor = [UIColor greenColor]; // Objective-C
template.line1ImageProvider?.tintColor = UIColor.greenColor() // Swift
有关详细信息,请参阅 CLKImageProvider Class Reference:
Two-piece images are displayed only in multicolor environments and take priority over one-piece images in those environments. A two-piece image consists of a foreground image layered on top of a background image. Both images are template images. ClockKit applies the color in the tintColor property to the background image, falling back to the color in the underlying template or white if no custom color is specified. ClockKit always applies a white color to the foreground image. Two-piece images are not used in monochrome environments.
我想显示一个多色的 Complication 图标,类似于默认计时器应用程序图标:
这是我用多色显示图标的代码:
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];
两幅图背景清晰。如何用白色为中心图像着色,用另一种颜色为外部图像着色?
使用 tintColor
属性 指定两件式图像背景的色调。
例如,如果您希望两张图片的背景颜色为绿色,您可以指定:
template.line1ImageProvider.tintColor = [UIColor greenColor]; // Objective-C
template.line1ImageProvider?.tintColor = UIColor.greenColor() // Swift
有关详细信息,请参阅 CLKImageProvider Class Reference:
Two-piece images are displayed only in multicolor environments and take priority over one-piece images in those environments. A two-piece image consists of a foreground image layered on top of a background image. Both images are template images. ClockKit applies the color in the tintColor property to the background image, falling back to the color in the underlying template or white if no custom color is specified. ClockKit always applies a white color to the foreground image. Two-piece images are not used in monochrome environments.