混合 CATextLayer 和 CAScrollLayer

发布于 2024-12-18 12:39:44 字数 171 浏览 5 评论 0原文

我需要一个可滚动的 CATextLayer 来显示 NSAttributedString。 有没有办法混合两个图层,或者向 CATextLayer 添加滚动或在 CAScrollLayer 中显示文本?

抱歉,如果问题不太准确。 谢谢!

编辑:我还没有看到 CALayer 是可滚动的。 对不起!

I need a scrollable CATextLayer to display a NSAttributedString.
Is there any way to mix both layers, or to add a scroll to CATextLayer or to display text in a CAScrollLayer?

Sorry if the question isn't very exact.
Thanks!

EDIT: I haven't seen that the CALayer is scrollable.
Sorry!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-12-25 12:39:44

尝试将其添加到您的示例中以编程方式滚动图层:

- (void)scroll {
    [scrollLayer scrollToPoint:scrollPoint];
    scrollPoint.x += 10;
    [self performSelector:_cmd withObject:nil afterDelay:0.1];
}

并将其添加到初始化方法的末尾:

scrollPoint = CGPointMake(0, 0);
[self scroll];

Try adding this to your example to scroll the layer programmatically:

- (void)scroll {
    [scrollLayer scrollToPoint:scrollPoint];
    scrollPoint.x += 10;
    [self performSelector:_cmd withObject:nil afterDelay:0.1];
}

and add this at the end of the initialize method:

scrollPoint = CGPointMake(0, 0);
[self scroll];
俯瞰星空 2024-12-25 12:39:44

CALayer(和 CATextLayer)可以滚动

CALayer (and CATextLayer) can be scrolled

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文