gpt4 book ai didi

objective-c - TwoPieceImage 复杂化

转载 作者:行者123 更新时间:2023-12-02 21:07:59 25 4
gpt4 key购买 nike

我想显示一个多色复杂功能图标,类似于默认计时器应用程序图标:

enter image description here

这是我用多色显示图标的代码:

CLKComplicationTemplateModularSmallStackImage* template=[[CLKComplicationTemplateModularSmallStackImage alloc]init];

template.line1ImageProvider=[CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"Complication/Modular"]
twoPieceImageBackground:[UIImage imageNamed:@"ComplicationForeground/Modular"]
twoPieceImageForeground:[UIImage imageNamed:@"ComplicationBackgroud/Modular"]];

entry = [CLKComplicationTimelineEntry entryWithDate:[NSDate date]
complicationTemplate:template];

两幅图像都有清晰的背景。如何用白色为中心图像着色,用另一种颜色为外部图像着色?

最佳答案

使用 tintColor 属性指定两片图像背景的色调颜色。

例如,如果您希望两片图像背景颜色为绿色,您可以指定:

template.line1ImageProvider.tintColor = [UIColor greenColor]; // Objective-C

template.line1ImageProvider?.tintColor = UIColor.greenColor() // Swift

欲了解更多信息,请参阅CLKImageProvider Class Reference :

Two-piece images are displayed only in multicolor environments and take priority over one-piece images in those environments. A two-piece image consists of a foreground image layered on top of a background image. Both images are template images. ClockKit applies the color in the tintColor property to the background image, falling back to the color in the underlying template or white if no custom color is specified. ClockKit always applies a white color to the foreground image. Two-piece images are not used in monochrome environments.

关于objective-c - TwoPieceImage 复杂化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35072018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com