简体   繁体   English

iPhone在uitextView中将背景图像设置为文本?/

[英]Iphone Set background image into text in uitextView?/

I have a uiimageView containing the text like this . 我有一个uiimageView包含像文本这样

I want to set the image background of the text to look like this instead . 我想将文本的图像背景设置为如下所示

Please help me! 请帮我! Thanks! 谢谢!

You will need to combine an image of the text with the background image (the stuff that is supposed to fill the inside of the text) using compositing . 您将需要使用合成将文本图像与背景图像(应该填充文本内部的内容) 组合在一起。 Take a look at the various blend modes you can use, or look into the use of CIFilter. 看一下可以使用的各种混合模式,或者看一下CIFilter的使用。

http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/doc/c_ref/CGBlendMode 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 https://developer.apple.com/library/mac/#documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html

The thing in the background looks like it might be a gradient. 背景中的东西看起来可能是渐变的。 Again, you can use a CIFilter to generate that gradient, or you can use Core Graphics. 同样,您可以使用CIFilter生成该渐变,也可以使用Core Graphics。 So you'll composite the drawn text with its fill image, then you'll draw that over a gradient. 因此,将绘制的文本与其填充图像进行合成,然后将其绘制在渐变上。

代替黑色纯色文本,将具有透明文本和外部区域的图像作为所需的灰色渐变,然后将此图像放在背景图像上,即可得到所需的结果。

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

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