是否可以在 OSX 中使用自由形状作为窗口?

发布于 2024-10-07 14:57:55 字数 100 浏览 0 评论 0原文

我想使用自由形状(例如部分透明的图像)作为窗口背景,而不使用标准的关闭和最大化按钮。就像小部件一样。这在 OSX 中可能吗?我找不到任何相关信息或使用它的应用程序。

谢谢

I want to use a free form shape (e.g. A partially transparent image) as a window backgound without the standard close and maximise buttons. Like the widgets do. Is that possible in OSX? I could not find any info on that or an app that uses this.

Thanks

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

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

发布评论

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

评论(1

莫相离 2024-10-14 14:57:55

是的。您可以通过子类化 NSWindow 使其无边框且透明来实现此目的。您还将创建 NSView 的子类以绘制可见的自定义形状,然后使用此视图的实例作为窗口的内容视图。结果将是一个窗口,其唯一可见的部分将是您的内容视图绘制的形状。

这是一篇很好的带有示例的文章

Yes. You can do this by subclassing NSWindow to make it borderless and transparent. You'll also subclass NSView to draw the visible custom shape, then use an instance of this view as the window's content view. The result will be a window whose only visible parts will be the shape your content view draws.

Here's a good article with an example.

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