如何在 UILabel 文本上放置纹理
我想在 UILabel.text 上有一个纹理。
这样做我对 UILabel 进行了子类化。使用 -drawTextInRect 方法,我尝试仅获取用于使用 CGImageMaskCreate 函数创建图像蒙版的文本。
一旦从文本中获得该图像蒙版,我将尝试通过调用函数 CGImageCreateWithMask 使用它来创建新图像。
这可能吗?
这是正确的做法吗?
如何从 UILabel.text 获取图像蒙版?
I would like to have a texture on UILabel.text .
Doing so I subclassed UILabel. Using the -drawTextInRect method, I am trying to get only the text for creating an image mask with the function CGImageMaskCreate.
Once having that image mask from text I am trying to use it to create a new image by calling the function CGImageCreateWithMask.
Is that even possible?
Is that the right approach?
How do I get an image mask from the UILabel.text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将文本颜色设置为图案图像即可:
结果:
You can just set text color to pattern image:
Result:
使用此代码。它可能对你有帮助。
Use this code. It may help you.