swift - 自定义目录图标 Swift

标签 swift macos icons nsfilemanager

<分区>

我有代码:

do {
    try manager.createDirectory(atPath: appDir!.appendingPathComponent(path).path, withIntermediateDirectories: true, attributes: nil)
} catch {
    print("Error: \(error)")
}

如何将自定义图标添加到目录(如 Dropbox、Creative Cloud 等)?我是否将其添加为属性?

最佳答案

知道了!

NSWorkspace.shared().setIcon(#imageLiteral(resourceName: "customFolder"), forFile: appDir!.appendingPathComponent("/Files").path, options: NSWorkspaceIconCreationOptions.excludeQuickDrawElementsIconCreationOption)

用那个。

关于swift - 自定义目录图标 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45927803/

相关文章:

iOS swift : Save/restore scroll position when recycling cells

arrays - UITableViewCell 如何知道要从数组或字典加载什么 JSON

c++ - 我可以使用什么 Mac/iOS/Portable 库来格式化信息以打印到标签纸上?

macos - 获取文件的图标或缩略图

macos - 在 OS X 上安装 ROS2 - 错误 : No module named 'rclpy._rclpy'

web - 如何将多包 flaticons 合并为一包?

ios - 如何保存 MKMapItem 类型的数组

ios - 如何在 MVVM 模型中使用 MKMapViewDelegate 方法

blackberry - 如何在我的自定义 Blackberry 弹出对话框中使用默认对话框图标?

ios - 是否允许让备用应用程序图标是动态的?