我正在为我的watchOS 2应用程序设置复杂的功能。
我想提供三种不同类型的复杂功能:
- 实用小型
- 模块化最小项
- 圆形小型
所有这些复杂类型都应仅显示我的应用程序图标作为图像。在我的ClockKit类中,我已经实现了以下方法:
func getCurrentTimelineEntryForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTimelineEntry?) -> Void) {
if complication.family == .CircularSmall {
let template = CLKComplicationTemplateCircularSmallRingImage()
template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "app_icon")!)
let timelineEntry = CLKComplicationTimelineEntry(date: NSDate(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .UtilitarianSmall{
let template = CLKComplicationTemplateUtilitarianSmallRingImage()
template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "app_icon")!)
let timelineEntry = CLKComplicationTimelineEntry(date: NSDate(), complicationTemplate: template)
handler(timelineEntry)
} else if complication.family == .ModularSmall {
let template = CLKComplicationTemplateModularSmallRingImage()
template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "app_icon")!)
let timelineEntry = CLKComplicationTimelineEntry(date: NSDate(), complicationTemplate: template)
handler(timelineEntry)
} else {
handler(nil)
}
}
我不确定这是否是实现我的想法的适当方式,因此我想知道仅显示图像作为我的复杂化的代码。有人知道我如何实现这个吗?