watchOS Complication Extra Large Image
Extra Large Image
3種類
-
CLKComplicationTemplateExtraLargeRingImage
CLKComplicationTemplateExtraLargeSimpleImage
CLKComplicationTemplateExtraLargeStackImage
CLKComplicationTemplateExtraLargeRingImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
switch complication.family {
case .extraLarge:
let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "goodwill146")!)
let extraLargeTemplate = CLKComplicationTemplateExtraLargeRingImage()
extraLargeTemplate.imageProvider = imageProvider
extraLargeTemplate.ringStyle = .closed
extraLargeTemplate.fillFraction = 0.5
let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: extraLargeTemplate)
handler(entry)
default:
handler(nil)
}
}
色は盤面カスタマイズで指定した色が反映されます。
CLKComplicationTemplateExtraLargeSimpleImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
switch complication.family {
case .extraLarge:
let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "goodwill224")!)
let extraLargeTemplate = CLKComplicationTemplateExtraLargeSimpleImage()
extraLargeTemplate.imageProvider = imageProvider
let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: extraLargeTemplate)
handler(entry)
default:
handler(nil)
}
}
CLKComplicationTemplateExtraLargeStackImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
switch complication.family {
case .extraLarge:
let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "goodwill192x102")!)
let textProvider = CLKSimpleTextProvider(text: "Text")
let extraLargeTemplate = CLKComplicationTemplateExtraLargeStackImage()
extraLargeTemplate.highlightLine2 = false
extraLargeTemplate.line1ImageProvider = imageProvider
extraLargeTemplate.line2TextProvider = textProvider
let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: extraLargeTemplate)
handler(entry)
default:
handler(nil)
}
}










