gpt4 book ai didi

objective-c - 如何为 NSAppearance 制作 "appearance file"?

转载 作者:太空狗 更新时间:2023-10-30 03:13:45 25 4
gpt4 key购买 nike

我在阅读 Cocoa 文档时无意中发现了 10.9 API 中的一些新功能。

From the docs我收集到 NSAppearance 类和相关协议(protocol) NSAppearanceCustomization 似乎是一种自定义 NSView 及其后代外观的方法。

An NSAppearance object represents a file that specifies a standard or custom appearance that applies to a subset of UI elements in an app. An app can contain multiple appearance files and—because NSAppearance conforms to NSCoding—you can use Interface Builder to assign UI elements to an appearance.
Typically, you customize a window by using Xcode to create an appearance file that contains the views you want to customize and the custom art that should be applied to them. Xcode transforms the file’s art content into a runtime format that AppKit can draw when the specified views are displayed.

好吧,这一切听起来很简洁,很有前途,但在文档中的任何地方我都找不到外观文件是什么或如何制作外观文件。除了我已经阅读过的薄文档外,谷歌搜索结果为空。

我确实看到 UIKit 有一个类似的 UIAppearance 类,但据我所知,这不是 UIKit 类的直接移植。

有谁知道如何制作这些神奇的“外观文件”之一以及我们究竟可以用它们做什么?

最佳答案

有一个名为“CoreThemeDefinition”的私有(private)框架来处理 uicatalog 文件,这些文件可以变成“.car”文件并使用 NSAppearance 加载。我个人认为 Apple 将来会在 Xcode 中包含一个编辑器,但现在您可以使用我制作的这个小工具:https://github.com/insidegui/AppearanceMaker

您首先打开应用程序并选择一个位置来保存 uicatalog 文件,然后单击“创建骨架”。这将导出包含控件默认图像的各种 PSD,然后您可以使用该应用编辑它们、保存和导出汽车文件。

此文件需要包含在您应用的资源中,您可以使用以下方式加载此自定义外观:

[[NSAppearance alloc] initWithAppearanceNamed:@"Your-appearance-name" bundle:nil]

关于objective-c - 如何为 NSAppearance 制作 "appearance file"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19780577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com