设置mac应用程序图标

    技术2022-05-19  20

    //获取束路径

    NSString *strBundlePath = [[NSBundle mainBundle] bundlePath];

    //获取目录

    NSString * strBundleDir = [strBundlePath stringByDeletingLastPathComponent];

    //合成图标资源的全路径

    NSString *strIconPath = [strBundleDir stringByAppendingPathComponent:@"app.ico"];

    //读取图标文件

    NSImage *myAppIcon = [[NSImage alloc] initWithContentsOfFile: strIconPath];

    //得到当前的主程序

    NSApplication *currentApp = [NSApplication sharedApplication];

    //设置程序图标

    [currentApp setApplicationIconImage: myAppIcon];

    //释放资源

    [myAppIcon release];


    最新回复(0)