iTunes 风格的 NSWindow 子类?
Cocoa 是否有一个开源库可以创建遵循 iTunes 风格的窗口?也就是说,窗口控件是垂直布局而不是水平布局:
我发现它节省空间且实用- 类型的应用程序不需要窗口标题。
Is there an open-source library for Cocoa to create a window following iTunes' style? That is the window controls are laid out vertically instead of horizontally:
I find it space-saving and good for utility-type applications that doesn't need a window title.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个快速破解的 NSWindow delegate 应该可以帮助你开始:
但是我不得不说,就像 JeremyP 一样,我只能希望 Apple 不会在 OS X 中更广泛地传播它。
This quickly hacked away NSWindow delegate should get you started:
However I got to say that just like JeremyP I can only hope Apple's not going to spread this any wider in OS X.
只是基于 @Regexident 的新 macOS 的修改版本。新的 macOS UI 的视图层次结构发生了变化,因此原始版本不起作用。修改后的代码如下(适用于macOS 10.13):
结果截图:
Just a modified version based on @Regexident 's for new macOS. The view hierarchy changed for new macOS UI, so the original version does not work. The modified code is as follows (works on macOS 10.13):
Result screenshot:
您可能必须继承 NSWindow、NSView 并自己绘制窗口和按钮。
哦,只是想补充一点,在进行自定义绘图时,您会丢失一些非常重要的细节。由于绘图是在主线程中完成的,并且您的主线程可能会忙于执行一些繁重的重要任务,从而阻塞主线程执行一段时间,因此用户将无法移动窗口,并且按钮鼠标悬停动画将不起作用。
当然,除非您在另一个线程中实现鼠标侦听事件,在那里进行绘图,锁定焦点...我的意思是 - 不要打扰,除非您真的认为这会让您的应用程序变得更好:)
You'll probably have to subclass NSWindow, NSView and do the window and buttons drawing yourself.
Oh and just wanted to add that you lose some quite important details doing custom drawing. Since the drawing is done in the main thread and your main thread might get busy doing some heavy important task blocking the main thread execution for a while, user won't be able to move the window and they button mouse over animation won't work.
Unless of course you implement mouse listening events in another thread, do the drawing there, lock focus... What I meant was - don't bother unless you really think this will make your app much better :)