当我们新建了一个文档,保存的时候,Mac系统会弹出一个保存对话框,对话框里面有一个控件,可以选择保存路径
我通过继承NSPopupButton的类SYXPathPopupButton实现相同的效果,并加上了tooltips。如图所示:
1、实例化一个SYXPathPopupButton对象pathPopupButton
2、设置“个人收藏目录”与“最近打开的目录”
self.pathPopupButton.defaultDirs =[[NSMutableArray alloc] initWithObjects:[@"~/Desktop" stringByStandardizingPath], [@"~" stringByStandardizingPath], [@"~/Downloads" stringByStandardizingPath], [@"~/Movies" stringByStandardizingPath], [@"~/Music" stringByStandardizingPath], [@"~/Pictures" stringByStandardizingPath], [@"~/Documents" stringByStandardizingPath],nil]; self.pathPopupButton.recentDirs = [[NSMutableArray alloc] initWithObjects:[@"~/Desktop" stringByStandardizingPath], [@"~/Applications" stringByStandardizingPath], [@"/users" stringByStandardizingPath], [@"/bin" stringByStandardizingPath],nil]; [self.pathPopupButton reloadData];