GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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+

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and more!

Learn more here

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.