.bundle的制作

来源:互联网 发布:js 打开ie浏览器 编辑:程序博客网 时间:2024/06/06 09:49



通常 制作静态库 里边需要图片的时候会出现加载不了图片的情况和图片重名的情况 为了防止这种情况 通常是以下的方式

1.制作bundle

新建文件夹 后缀名改为".bundle";并将图片拖入.bundle中

2.将bundle拖到工程中

3.使用图片

注意:使用图片的时候不能直接用imageNamed的方法了 是以下的方法:

 NSString *imagePath = [[NSBundlemainBundle]pathForResource:@"lufy.png"ofType:nilinDirectory:@"LibStatic.bundle"];

    return [UIImageimageWithContentsOfFile:imagePath];


直接用图片名命名的方法

hud.customView = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:[NSStringstringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];


效果如下图:


0 0