简体   繁体   English

核心图形色彩融合

[英]Core graphics color blending

I have a line of text which I want to display behind a CALayer, and when behind, then the text color should appear in a different color in the overlapping area. 我要在CALayer后面显示一行文本,当在后面时,则该文本颜色应在重叠区域以另一种颜色显示。

The color of the text is black, and the text color should appear as white on the red layer when they overlap (they may both move around, so this needs to be continuously updated). 文本的颜色为黑色,当它们重叠时,文本颜色应在红色层上显示为白色(它们可能都在周围移动,因此需要不断更新)。

How may this be accomplished? 如何做到这一点?

This can't be done with any blend mode. 任何混合模式都无法做到这一点。 You'll need to render the text into the foreground layer in white by hand. 您需要手工将文本呈现为白色的前景层。

One trick you could try is to keep the white text always visible, but clipped by the layer that moves around using a second layer that also moves, set as the text's mask. 您可以尝试的一种技巧是使白色文本始终可见,但是通过第二层也被移动的层(被设置为文本的遮罩)来裁剪被四处移动的层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM