IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Mac系统中选择保存路径的控件的实现

    helloitworks发表于 2014-05-20 08:50:17
    love 0

    Mac系统中选择保存路径的控件

    当我们新建了一个文档,保存的时候,Mac系统会弹出一个保存对话框,对话框里面有一个控件,可以选择保存路径
    我通过继承NSPopupButton的类SYXPathPopupButton实现相同的效果,并加上了tooltips。如图所示:
    1cef770eda080865b0cf6b07b037bf10

    使用方法

    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];
    

    源代码:
    https://github.com/helloitworks/SYXPathPopupButton



沪ICP备19023445号-2号
友情链接