Complication image assets

I've added images to the Complication group in Assets.xcassets within my WatchKit Extension but I can't figure out how to load one of these images as a UIImage in code. Can anyone help me out with this?


I just watched the "Creating Complications with ClockKit" WWDC video but the code sample just used UIImage(named: "Background") and UIImage(named: "Foreground")


Thanks

Here is what you need to get started.


https://developer.apple.com/library/prerelease/watchos/documentation/ClockKit/Reference/CLKImageProvider_class/index.html#//apple_ref/occ/cl/CLKImageProvider


The images themselves essetnially need to be alpha transparent so the user can change the color on the clock face and it will match. Also, you'll need to look at each complication family and make sure you're putting the imagine in the correct place in the template.

Problem solved. Basically I hadn't had any experience with Asset Catalog groups and wasn't including the group name when initializing my UIImage.


The code I was looking for was:


UIImage(named: "Complication/Circular")

UIImage(named: "Complication/Modular")

and

UIImage(named: "Complication/Utilitarian")


Thanks

I'm finding this very confusing and buggy. Xcode seems to want you to use the Complication Asset Catalog folder (it creates them in new projects) and wants very specific sizes for the images. It produces build warnings if these sizes are not used:


Circular: 32x32px for 38mm and 36x36px for 42mm

Moduar: 52x52px for 38mm and 58x58px for 42mm

Utilitarian: 40x40px for 38mm and 44x44px for 42mm


Firstly, I find it odd that you need to use the "Complication/" prefix when specifying the name for each image. That's never been the case for asset catalogs in the past.


The documentation lists specific sizes for the various different complication templates and apart from circular small simple image and modular small simple image the sizes don't match what Xcode wants. The images I provide are not being scaled down in some cases, and are being scaled vertically but not horizontally in other cases.


The Big Nerd Ranch blog post on complications implies you can just use normal asset class logic to load images (no prefixes, no special asset catalog Complication group). I won't include a link in this post because that will require it to be moderated. Search for "big nerd ranch watchos2 complication". So what's the special Xcode asset class support, the "Watch Complication Name" build setting and the section in the General project settings tab for the Watch extension target for?


What's the right way to specify the different image sizes for different complications?

Thank you - adding the 'namespace' did the trick for me.


It would be good to hear from Apple (Hey @apple ) if this is the new starndard or just a beta bug,

Complication image assets
 
 
Q