How to put texture in UILabel text

I would like to have a texture in UILabel.text.

Having done this, I have subclassed UILabel. Using the -drawTextInRect method, I try to get only text to create an image mask using the CGImageMaskCreate function.

After this image mask from the text I try to use to create a new image by calling the function CGImageCreateWithMask.

Is it possible?

Is this the right approach?

How to get image mask from UILabel.text?

+4
source share
2 answers

You can simply set the text color for the image image:

label.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"texture"]]; 

Result:

Sample

+2
source

Use this code. It can help you.

 lbl.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"img"]]; 
0
source

Source: https://habr.com/ru/post/1346371/


All Articles