我正在.graphicCorner
使用模板创建 ClockKit 复杂功能CLKComplicationTemplateGraphicCornerTextImage
。正如 Tech Talk Developing Complications for Apple Watch Series 4中所述,应该可以组合多个不同颜色的 Text Providers。
不幸的是,我可以让它工作。
这是我的代码ComplicationController.swift
func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
switch complication.family {
…
case .graphicCorner:
if #available(watchOSApplicationExtension 5.0, *) {
let template = CLKComplicationTemplateGraphicCornerStackText()
let firstTextProvider = CLKSimpleTextProvider(text: "first")
firstTextProvider.tintColor = UIColor.green
let secondTextProvider = CLKSimpleTextProvider(text: "second")
secondTextProvider.tintColor = UIColor.red
let thirdTextProvider = CLKSimpleTextProvider(text: "third")
thirdTextProvider.tintColor = UIColor.blue
template.outerTextProvider = firstTextProvider
template.innerTextProvider = CLKTextProvider.localizableTextProvider(withStringsFileFormatKey: "STRINGFORMAT", textProviders: [secondTextProvider, thirdTextProvider])
handler(template)
} else {
handler(nil) // Fallback on earlier versions
}
default:
handler(nil)
}
}
和我的内容ckcomplication.strings
"STRINGFORMAT" = "%@ %@";
不会显示任何文字。我在这里做错了什么?我感谢任何想法或工作示例。