我在网上找不到任何文档来说明如何添加Watch Series 4上可用的任何新的“图形”复杂功能。这些是我的步骤:
(1)添加了符合CLKComplicationDataSource
的类(下面的代码)
(2)将并发症配置设置为指向(1)和“并发症”资产文件夹
(4)从Sketch导出png并将其拖动到Complications资产文件夹中,以Modular / Utilitarian / Circular
复杂性资产文件夹中的图形(角,边框和圆形)占位符将不接受png(仅pdf)。毕竟,旧的模块化实用程序和圆形并发症可以正常工作,但是图形的图像(pdf) (转角,边框和圆形)无法在设备上呈现
import Foundation
import ClockKit
class HockeyTrackerComplication: NSObject, CLKComplicationDataSource {
func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
handler([])
}
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
if #available(watchOSApplicationExtension 5.0, *) {
if complication.family == .circularSmall {
let template = CLKComplicationTemplateCircularSmallRingImage()
guard let image = UIImage(named: "Circular") else { handler(nil); return}
template.imageProvider = CLKImageProvider(onePieceImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .utilitarianSmall {
let template = CLKComplicationTemplateUtilitarianSmallRingImage()
guard let image = UIImage(named: "Utilitarian") else { handler(nil); return}
template.imageProvider = CLKImageProvider(onePieceImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .modularSmall {
let template = CLKComplicationTemplateModularSmallRingImage()
guard let image = UIImage(named: "Modular") else { handler(nil); return}
template.imageProvider = CLKImageProvider(onePieceImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .graphicCircular {
let template = CLKComplicationTemplateGraphicCircularImage()
guard let image = UIImage(named: "GraphicCircular") else { handler(nil); return}
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .graphicBezel {
let template = CLKComplicationTemplateModularSmallRingImage()
guard let image = UIImage(named: "GraphicBezel") else { handler(nil); return}
template.imageProvider = CLKImageProvider(onePieceImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .graphicCorner {
let template = CLKComplicationTemplateGraphicCornerCircularImage()
guard let image = UIImage(named: "GraphicCorner") else { handler(nil); return}
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else {
handler(nil)
}
} else {
// Fallback on earlier versions
}
}
}
答案 0 :(得分:1)
我的问题是我没有实现lists_to_delete = set(list_x) - set(list_y)
https://developer.apple.com/documentation/clockkit/clkcomplicationdatasource/1650686-getlocalizablesampletemplate,尽管它被列为可选,并且不是实现x=0
n=input('What is the integer value of n? n= ')
while (int(n)<=10000):
n=(int(n))**(int(x))
x += 1
print(int(n))
的必需方法的一部分,但使我的图像复杂化了。
答案 1 :(得分:0)
转换下一个:
图像资产,配置图像集>屏幕宽度>单独宽度 并将图像设置为手表尺寸区域(38mm,40mm,42mm,44mm)。
适合我的情况。