聊天泡泡可可

发布于 2024-08-17 15:39:23 字数 454 浏览 3 评论 0原文

我已经尝试创建一个聊天气泡大约一个月了......(你知道,就像 iChat 或 Tweetie 中的聊天气泡)。在某个时候,我发现一个线程说我可以使用 Twitterfon 的源代码......我确实这样做了。但我由于几个原因陷入困境。哪些?苹果似乎没有实现计算矩形大小所需的所有方法。例如: NSTextField 没有实现允许我给出 NSRect 以便它计算最佳大小的方法。事实上,Tweetie 的泡泡直肠总是完美的。我给他写了一封信,询问他是怎么做到的,但没有得到回复。虽然,我理解,因为它是用于商业应用。我认为随着 iPhone 的 SMS 应用程序(以及 iChat,或任何包括聊天气泡的应用程序)的流行,有人可能会在 OS X 上实现,并将其开源。我经验不是很丰富,主要是我没有时间(学校),所以这就是为什么我已经研究了一个月但还没有找到解决方案。

如果有人在 Cocoa 上创建了这个东西,他们能解释一下他们的解决方案吗?或者更好的是,显示一些代码......

I have been trying to create a chat bubble for about a month now... (you know, like the one in iChat or Tweetie). At some point I found a thread that said that I could use Twitterfon's source... which I did. But I get stuck for a few reasons. Which ones? Apple didn't seem to implement all the methods needed for calculating the rect's size. E.g.: NSTextField doesn't implement a method that allows me to give an NSRect in order for it to calculate the best size. The fact is, Tweetie's bubble rects are always perfect. I dropped him a line asking how he did that, but I didn't get a reply. Although, I understand, because it is used in a commercial application. I thought that with the popularity of iPhone's SMS application (and iChat, or any app including chat bubbles), someone would probably made an implementation on OS X, and made it open source. I am not very experienced, and mainly I don't have time (school), so this is why I have been working on it for one month and have not found a solution.

If someone created the thing on Cocoa, would they please explain their solution for it ? Or even better, show some code...

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

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

发布评论

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

评论(3

z祗昰~ 2024-08-24 15:39:23

AppKit NSString Additions 具有测量绘图字符串的方法,对于更高级的目的,您可以使用 NSLayoutManager。有关详细信息,请参阅文本布局编程指南

The AppKit NSString Additions have methods to measure strings for drawing, and for more advanced purposes you can use NSLayoutManager. See the Text Layout Programming Guide for more info.

℉服软 2024-08-24 15:39:23

或者,您可以使用 WebKit 和 HTML/CSS。我相信这就是 Adium 实现其 IM 消息主题的方式。

Alternatively you could use WebKit and HTML/CSS. I believe this is how Adium achieve their IM message themes.

夜吻♂芭芘 2024-08-24 15:39:23

查看 BubbleThingie 示例代码,了解如何处理图像的示例掩蔽。它还提供了如何使用 UIButton 或 UILabel 生成文本气泡并进行所有大小计算的示例。它还允许将气泡着色为任何颜色。

在此处输入图像描述

Check out the BubbleThingie sample code for example of how to do the image masking. It also has example of how to do the text bubbles using a UIButton or UILabel and does all the size calculations. it also allows to tint the bubbles any color.

enter image description here

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