2017-09-25 13 views
1

コンプリケーションテンプレートイメージに色合いを追加しようとしています。ウォッチフェイスをカスタマイズするオプションをスクロールしているときに、色合いが正しく表示されます。しかし、合併症を選択して通常のウォッチフェイス状態に戻ると、色は白に戻ります。Apple Watchコンプリートティントカラー

- (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); 
} 

カスタマイズ: Tint is gone and it's back to a white image

+0

機能あなたの質問では、唯一の合併症を選択するときに表示され__template__の世話をします。実際の複雑なデータを準備する関数で同じ振る舞いを再現する必要があります。 –

+0

@DávidPásztorありがとうございます。それはトリックでした! – dyah

答えて

1

ダビデはコメントで述べたように、問題の関数は唯一テンプレートの世話をし、あなたがする必要がある:合併症後 Tint is correct while customizing

が選択されています実際の複雑なデータを準備する関数で同じ振る舞いを再現します。

選択フェーズを過ぎ色合いの色が持続するために、次のコードを追加します。

- (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]); 
} 
関連する問題