我有一个复杂的工作,我的苹果手表应用程序,我想增加第二种风格。我提出了一个非常基本的原型,但没有看到它可供选择的手表表面。所以我试着解决这个问题:
我的应用程序能支持不止一个并发症吗?,我可以在手表上同时运行两个并发症吗?(或者是这样,如果我有一个,iOS就不会显示第二个并发症?)我试着增加一个新的表脸,但它不允许我。
CLKComplicationTemplateModularSmallRingText 是 ModularSmall 类型并发症的有效模板吗?
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
if complication.family == .modularSmall {
let template = CLKComplicationTemplateModularSmallRingText()
template.ringStyle = .open
template.fillFraction = 0.3
let testProvider = CLKSimpleTextProvider(text: "TST", shortText: "S")
sleep.tintColor = UIColor.green
template.textProvider = testProvider
template.tintColor = UIColor.green
let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
// Pass the entry to ClockKit.
handler(entry)
}
else if complication.family == .graphicRectangular {
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
//this complication works...
}占位符模板目前是相同的:
func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
// Pass the template to ClockKit.
if complication.family == .modularSmall {
let template = CLKComplicationTemplateModularSmallRingText()
//...

我在复杂的占位符文件中看到了一个错误(但我正在一个44毫米的设备上进行测试)--将修复它并查看发生了什么。我是返回一个错误的图像或错误的模板类型的模块复杂性?我想要一个圆环规

发布于 2019-02-25 23:35:02
结果发现我被苹果的文件误导了。我需要使用GraphicCircular合并症(在WatchOS5中是新的)类型,而不是模块化(旧表脸)。
func circularTemplate() -> CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText{
let template = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText()
let gauge = CLKSimpleGaugeProvider(style: .ring, gaugeColor: UIColor.green), fillFraction: 0.3)
template.gaugeProvider = gauge
let random = arc4random() % 999
let middle = CLKSimpleTextProvider(text: "4.5", shortText: "4")
middle.tintColor = kRGBColorFromHex(0x657585)
template.tintColor = kRGBColorFromHex(0x657585)
template.centerTextProvider = middle
let bottom = CLKSimpleTextProvider(text: "-\(random)", shortText: "1..")
template.bottomTextProvider = bottom
return template
}新款式:

旧式:

https://stackoverflow.com/questions/54875838
复制相似问题