watchOS Complication Graphic Bezel

Apple Document

Developing Complications for Apple Watch Series 4

Graphic Bezel

Document

1種類

CLKComplicationTemplateGraphicBezelCircularText

    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