Apple Watch Complication Icon or Text

805 Views Asked by At


I made an Apple Watch App with Complication and activated the Modular Small one. I added the following code to ComplicationController.swift but I only get a square icon. Trying to put text or an image in it don't do anything.

func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
    var template: CLKComplicationTemplate?

    switch complication.family {
    case .modularSmall:
        template = CLKComplicationTemplateModularSmallSimpleText()
        (template as! CLKComplicationTemplateModularSmallSimpleText).textProvider = CLKSimpleTextProvider(text: "R")
    default:
        template = nil
    }
    handler(template)
}
1

There are 1 best solutions below

0
On

When you only put a template in the getPaceholderTemplete() method it will only be displayed in the list of templates that appears when you want to change complications.

After the complication has been selected it will call getCurrentTimelineEntry(). This is where you need to insert the template that you want to be displayed once the complication is activated. Your code looks fine, so if you just copy and paste your switch statement into getCurrentTimelineEntry() it should work.