简体   繁体   English

如何在我的 Mac Cocoa 应用程序中创建 iOS 风格的工具栏?

[英]How can I create an iOS-style toolbar in my Mac Cocoa application?

Several iLife '11 applications on the Mac use iOS-style black toolbars. Mac 上的几个 iLife '11 应用程序使用 iOS 风格的黑色工具栏。 For instance, the toolbar at the bottom of this screenshot of iPhoto:例如,这个 iPhoto 截图底部的工具栏:


(source: pocket-lint.com ) (来源: pocket-lint.com

This sort of look is available in the iOS SDK as "UITabBar."这种外观在 iOS SDK 中作为“UITabBar”提供。

I am wondering if there is an easy way to achieve this in my ordinary, non-iOS Mac application.我想知道是否有一种简单的方法可以在我的普通非 iOS Mac 应用程序中实现这一点。 If not, what would be the best way to go about creating this effect?如果不是,那么 go 关于创建这种效果的最佳方法是什么?

There's nothing that will give you this view out of the box.没有什么可以让您开箱即用地获得这种观点。 You'll need to build it yourself.您需要自己构建它。

The simplest method would be to create a custom view with a gradient background and place monochrome buttons in it.最简单的方法是创建一个带有渐变背景的自定义视图并在其中放置单色按钮。

Better would be to create a set of classes similar to NSToolBar that handle positioning, highlighting etc. Even better, build it and then open-source it:-)更好的是创建一组类似于NSToolBar的类来处理定位、突出显示等。更好的是,构建它然后开源它:-)

However, you'll have to build it yourself.但是,您必须自己构建它。 Apart from NSButton there's not much that will help in the pre-existing objects.除了NSButton之外,对预先存在的对象没有什么帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM