2
votes

I'm trying to add a tint color to a Complication Template image. When I'm scrolling through the options to customize my watch face, the tint color is correct. However, once I select the complication and return to the normal watch face state, the color switches back to white.

- (void)getLocalizableSampleTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {
  CLKComplicationTemplateModularSmallSimpleImage *modularTemplate = [[CLKComplicationTemplateModularSmallSimpleImage alloc] init];
  CLKImageProvider *imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"Complication/Modular"]];
  imageProvider.tintColor  = [UIColor colorWithRed:0.412 green:0.443 blue:0.773 alpha:1.000];
  modularTemplate.imageProvider = imageProvider;
  handler(modularTemplate);
}

Customizing: Tint is correct while customizing

After complication is selected: Tint is gone and it's back to a white image

1
The function in your question only takes care of the template which is shown when selecting a complication. You need to replicate the same behaviour in your functions preparing the actual complication data. - Dávid Pásztor
@DávidPásztor thank you. That did the trick! - dyah

1 Answers

2
votes

As David mentioned in the comments, the function in the question only takes care of the template and you need to replicate the same behavior in your functions preparing the actual complication data.

Add the following code to make the tint color persist past the selection phase:

- (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler {
  CLKComplicationTemplateModularSmallSimpleImage *template = [[CLKComplicationTemplateModularSmallSimpleImage alloc] init];
  CLKImageProvider *imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"Complication/Modular"]];
  imageProvider.tintColor  = [UIColor colorWithRed:0.412 green:0.443 blue:0.773 alpha:1.000];
  template.imageProvider = imageProvider;
  handler([CLKComplicationTimelineEntry entryWithDate:[NSDate date] complicationTemplate:template]);
}