TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SwiftUI view as complication

Forums > watchOS

Hi guys!

Me again and I’m wondering if there’s anyone out there who’s played with WatchKit and using SwiftUI views as complications. Going through wwdc20 vids atm but would love a tutorial or something so I can make sense of it all.

I'm closer now I think,

Ive created the descriptors for the complication view here:

func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
        var descriptors : [CLKComplicationDescriptor] = []
        descriptors.append(CLKComplicationDescriptor(identifier: "ComplicationView",
                                                     displayName: "Complication View",
                                                     supportedFamilies: [.circularSmall]))
        // Call the handler with the supported complication descriptors
        handler(descriptors)
    }

And now I have to create the template and I know this is wrong, but would love some pointers for some help. Thanks

func createTemplate(
        forComplication complication: CLKComplication,
        date: Date) -> CLKComplicationTemplate? {
        let defaultTemplate: (CLKComplicationFamily) -> CLKComplicationTemplate = { family -> CLKComplicationTemplate in
              // Return a default complication template for the given family
            }
        switch (complication.family, complication.identifier) {
            case (.circularSmall, "ComplicationView"):
                return CLKComplicationTemplateGraphicCircularView(ComplicationView())
        }

Thanks Mark

5      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.