自定义目录图标Swift

时间:2017-08-28 21:49:43

标签: swift macos icons nsfilemanager

我有代码:

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

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

1 个答案:

答案 0 :(得分:1)

知道了!

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

使用它。