watchOS Complication Graphic Bezel

Apple Document

Developing Complications for Apple Watch Series 4

Graphic Bezel

Document

1種類

CLKComplicationTemplateGraphicBezelCircularText

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
    switch complication.family {
    case .graphicBezel:
        let number = 1234
        let textProvider = CLKTextProvider(format: "TextA %d TextB", number)
 
        let imageProvider = CLKFullColorImageProvider(fullColorImage: UIImage(named: "kumonosu94")!)
        let circularTemplate = CLKComplicationTemplateGraphicCircularImage()
        circularTemplate.imageProvider = imageProvider
 
        let bezelTemplate = CLKComplicationTemplateGraphicBezelCircularText()
        bezelTemplate.textProvider = textProvider
        bezelTemplate.circularTemplate = circularTemplate
         
        let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: bezelTemplate)
 
        handler(entry)
    default:
        handler(nil)
    }
}

circularTemplateはGraphic CircularのTemplateが設定出来ます。

Swift

Posted by shi-n