Search code examples
iosswiftwatchkitwatchos-2apple-watch-complication

WatchOS Complication: is it possible to use custom text alignment?


I've been developing a watchOS 2 complication for my app. It's looking great... asides from one last thing I'd like to tweak.

Complication templates seem to provide text alignment that isn't quite what I want. For the purpose of this question, let's go with the following code:

let template = CLKComplicationTemplateModularSmallStackText()
template.line1TextProvider = CLKSimpleTextProvider(text: "Hi")
template.line2TextProvider = CLKSimpleTextProvider(text: "Bye")

Now, looking at the complication, the first line is centre aligned, while the second line is left aligned. Not a massive deal I know, but I'd really like both lines to be centre aligned... it would make my complication look much better!

I've been looking through the API docs and searched the web, and I can't see a way to do this (or anyone else that's tried to do the same thing).

Questions:

  • Has anyone else run into the same issue?
  • Is there something in the API that I've missed that lets you do this?
  • If not, is there any slightly more hacky/obtuse way of achieving what I'd like?

Solution

  • Unfortunately, you are limited by the predetermined layout that Apple has chosen for each particular template, and can't control the alignment.

    Filing a bug report is your best option to address any issue or request an enhancement.

    I can't reproduce your issue on watchOS 2.2 or 3.0 beta 1. line 2 is centered for that particular template.

    If you're supporting an earlier watchOS version which behaves differently, you could see if any Unicode space characters or textProviderWithFormat: would help to improve the appearance.