Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我做了一个CALayer *sublayerover 主视图,然后我添加CATextLayer了 over sublayer。
CALayer *sublayer
CATextLayer
sublayer
现在我想CATextLayer通过单击主视图上的按钮来显示文本。
我怎样才能做到这一点?
使用 设置按钮操作-[UIButton addTarget:selector:forControlEvents:]:,然后在该函数中将CATextLayers 字符串属性设置为 anNSString或 an NSAttributedString。
-[UIButton addTarget:selector:forControlEvents:]:
NSString
NSAttributedString
我提醒你,CATextLayer不尊重属性字符串上的段落设置,所以行高有点偏离,看起来不太好。