【问题标题】:TwoPieceImage Complication两件式图像并发症
【发布时间】:2016-01-28 21:05:58
【问题描述】:

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

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

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 为中心图像着色,用另一种颜色为外部图像着色?

【问题讨论】:

    标签: objective-c xcode watchkit watchos-2 apple-watch-complication


    【解决方案1】:

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

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

    template.line1ImageProvider.tintColor = [UIColor greenColor]; // Objective-C
    
    template.line1ImageProvider?.tintColor = UIColor.greenColor() // Swift
    

    更多信息,请参考CLKImageProvider Class Reference

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

    【讨论】:

      猜你喜欢
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      • 2013-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      相关资源
      最近更新 更多