When NSPathControl is used to represent path on local machine is fine!
The problem rise when I try to represent a virtual path of a remote server; in such case I have to change the icons accordingly.
The picture represents what I obtain that is not what I like.

Now the question: How to change the icon of each element of the NSPathControl? Apple documentation is quite opaque about.
The only similar post is Customise NSPathControl but seems quite outdated.
Masybe not the best, but is working.
class ViewController: NSViewController {
@IBOutlet weak var customPath: NSPathControl!
override func viewDidLoad() {
super.viewDidLoad()
customPath.pathItems = [
self.pathItem(title: "root", imageName: "root"),
self.pathItem(title: "First folder", imageName: NSImage.folderName),
self.pathItem(title: "Second folder", imageName: NSImage.folderName)
]
}
func pathItem(title: String, imageName: String) -> NSPathControlItem {
let item = NSPathControlItem()
item.title = title
item.image = NSImage(named: imageName)
return item
}
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With