Customise NSPathControl

雨燕双飞 提交于 2020-04-11 12:01:08

问题


I would like to make a custom NSPathControl. NSPathCell has the method + pathComponentCellClass, where you can return the custom class of the component cells. I have a NSPathComponentCell subclass, which I return right there, but it doesn't work. The method does not get called. Why?

In the documentation is says:

Subclasses can override this method to return a custom cell class that is automatically used. By default, the method returns [NSPathComponentCell class], or a specialized subclass thereof.

If this is wrong, is there another way to customise NSPathControl?


回答1:


I found the solution and posted it on github. I subclassed from NSPathControl. It's pretty simple actually.




回答2:


I have found that the component cell class is archived by IB. So, if a path control is set up in IB, it won't use your override of +pathComponentCellClass unless and until you change its URL after loading the NIB. There may be other changes that provoke it, too, like setting the path style.




回答3:


Have you tried to modify NSPathControlItem/attributedTitle:

(Limitation: macOS 10.10+)



来源:https://stackoverflow.com/questions/13368356/customise-nspathcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!