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.
我想使用 aCATextLayer以 a 的形式显示一些部分加粗的文本NSAttributedString- 但仍想使用 IB 的便利性进行定位。
CATextLayer
NSAttributedString
有没有办法加入一个CATextLayer带有界面的构建器?或者下一个最佳解决方案是什么?
UIView您可以在 IB 中配置一个子类,然后在代码中将其设置layerClass为:CATextLayer
UIView
layerClass
+ (Class)layerClass; { return [CATextLayer class]; }
在视图的init方法中配置您的CATextLayer属性。
init
要访问图层的属性:
CATextLayer *textLayer = (CATextLayer *)self.layer; textLayer.string = @"Foo"; // etc...