我需要一个可滚动的CATextLayer来显示NSAttributedString。是否有任何方法来混合这两个层,或添加滚动到CATextLayer或在CAScrollLayer中显示文本?
如果问题不是很准确,请原谅。谢谢!
编辑:我还没有看到CALayer是可滚动的。对不起!
尝试添加以下代码到您的示例中,以编程方式滚动图层:
- (void)scroll {
[scrollLayer scrollToPoint:scrollPoint];
scrollPoint.x += 10;
[self performSelector:_cmd withObject:nil afterDelay:0.1];
}
,并在initialize方法的末尾添加:
scrollPoint = CGPointMake(0, 0);
[self scroll];
CALayer(和CATextLayer)可以滚动