我想在点击按钮时设置CATextLayer的文本。怎么能实现?

时间:2012-08-17 05:49:40

标签: objective-c ios calayer catextlayer

我在主视图上制作了CALayer *sublayer,然后我在CATextLayer上添加了sublayer

现在,我想通过点击主视图上的按钮在CATextLayer上显示文字。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

使用-[UIButton addTarget:selector:forControlEvents:]:设置按钮操作,然后在该函数中将CATextLayer s字符串属性设置为NSStringNSAttributedString

我提醒你CATextLayer不尊重属性字符串的段落设置,因此行高有点偏,看起来不那么好。