向 Cocoa 标签添加阴影(凹陷文本效果),而不降低文本渲染质量

发布于 2024-08-11 05:54:41 字数 316 浏览 3 评论 0原文

我想创建带有文本效果的状态栏,如 Safari 或 iTunes 中的文本效果,即凹进文本。

example

但是,如果我只是使用 Core Animation 面板在 Interface Builder 中添加阴影,OS X 最糟糕的文本渲染就会出现:

wheres my subpixel

在标签上获取凹进文本并保持正确的子像素渲染的技巧是什么?

I'd like to create statusbar with text effect like in Safari or iTunes, i.e. recessed text.

example

However, if I simply add shadow in Interface Builder using Core Animation panel, OS X's worst text rendering kicks in:

wheres my subpixel

What's the trick to get recessed text on a label and keep proper subpixel rendering?

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

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

发布评论

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

评论(2

请止步禁区 2024-08-18 05:54:41

有一种内置方法可以做到这一点:

[[yourTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];

There is a built-in way to do this:

[[yourTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];
狼性发作 2024-08-18 05:54:41

这是一个廉价的老技巧:在一定偏移处以白色绘制文本,然后在其顶部绘制黑色文本。

文本绘制系统中有一个用于阴影的钩子,即 NSAttributedString 的 NSShadowAttributeName。但经过测试,它似乎也消除了子像素抗锯齿功能。

It's a cheap old trick: You draw the text in white at an offset and then draw the black text on top of it.

There is a hook for shadows in the text-drawing system, NSAttributedString's NSShadowAttributeName. But testing this out, it appears to kill the subpixel antialiasing as well.

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