Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个uiimageView包含这样的文本。
uiimageView
我想将文本的图像背景设置为看起来像这样。
请帮我!谢谢!
您需要使用compositing将文本图像与背景图像(应该填充文本内部的东西)结合起来。查看您可以使用的各种混合模式,或查看 CIFilter 的使用。
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/doc/c_ref/CGBlendMode
https://developer.apple.com/library/mac/#documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html
背景中的东西看起来可能是渐变。同样,您可以使用 CIFilter 来生成渐变,也可以使用 Core Graphics。因此,您会将绘制的文本与其填充图像合成,然后将其绘制在渐变上。
代替黑色纯色文本,将带有透明文本和外部区域的图像制作为您想要的灰色渐变,并将此图像放在您的背景图像上,您将获得所需的结果。