在Mac OS X中绘制桌面

时间:2023-01-24 08:59:55

I want to create analog of program conky. What is the best way to draw information on a OS X desktop?

我想创建程序conky的模拟。在OS X桌面上绘制信息的最佳方法是什么?

3 个解决方案

#1


NSWindow has a method, setLevel:, that lets you control how the window is positioned compared to other windows. From my own experience, you might want to try feeding it kCGDesktopIconWindowLevel, and calling setHasShadow:NO to implement the look you want. To actually do the drawing you would put a custom NSView subclass in your window, and create the window without a frame (see NSBorderlessWindowMask) and transparent ([window setBackgroundColor:[NSColor clearColor]], [self setOpaque:NO];).

NSWindow有一个方法setLevel:,它允许您控制窗口与其他窗口相比的位置。根据我自己的经验,你可能想尝试喂它kCGDesktopIconWindowLevel,并调用setHasShadow:NO来实现你想要的外观。要实际绘制,你可以在窗口中放置一个自定义的NSView子类,并创建一个没有框架的窗口(参见NSBorderlessWindowMask)和透明([window setBackgroundColor:[NSColor clearColor]],[self setOpaque:NO];)。

You might also want to take a look at this article to keep your window pinned to the desktop during an Expose event.

您可能还想查看本文,以便在Expose事件期间将窗口固定到桌面。

#2


Have you tried GeekTool? Maybe you don't even have to write the app. ☺

你试过GeekTool吗?也许你甚至不必编写应用程序。 ☺

#3


You need to take a look at using NSWindowLevel with a transparent window.

您需要查看使用NSWindowLevel和透明窗口。

#1


NSWindow has a method, setLevel:, that lets you control how the window is positioned compared to other windows. From my own experience, you might want to try feeding it kCGDesktopIconWindowLevel, and calling setHasShadow:NO to implement the look you want. To actually do the drawing you would put a custom NSView subclass in your window, and create the window without a frame (see NSBorderlessWindowMask) and transparent ([window setBackgroundColor:[NSColor clearColor]], [self setOpaque:NO];).

NSWindow有一个方法setLevel:,它允许您控制窗口与其他窗口相比的位置。根据我自己的经验,你可能想尝试喂它kCGDesktopIconWindowLevel,并调用setHasShadow:NO来实现你想要的外观。要实际绘制,你可以在窗口中放置一个自定义的NSView子类,并创建一个没有框架的窗口(参见NSBorderlessWindowMask)和透明([window setBackgroundColor:[NSColor clearColor]],[self setOpaque:NO];)。

You might also want to take a look at this article to keep your window pinned to the desktop during an Expose event.

您可能还想查看本文,以便在Expose事件期间将窗口固定到桌面。

#2


Have you tried GeekTool? Maybe you don't even have to write the app. ☺

你试过GeekTool吗?也许你甚至不必编写应用程序。 ☺

#3


You need to take a look at using NSWindowLevel with a transparent window.

您需要查看使用NSWindowLevel和透明窗口。