I want to set text of CATextLayer on click of button. how can it be achieved?

257 Views Asked by At

I made a CALayer *sublayer over the main view, then I added CATextLayer over sublayer.

Now I want to show text on the CATextLayer by clicking a button on my main view.

How can I do this?

1

There are 1 best solutions below

1
On

Set the buttons action using -[UIButton addTarget:selector:forControlEvents:]:, then in that function set the CATextLayers string property to either an NSString or an NSAttributedString.

I remind you that CATextLayer doesn't respect paragraph settings on attributed strings, so line height is kind of off and does not look so great.