zoukankan      html  css  js  c++  java
  • Bundle

    iOS开发中为了方便管理资源文件,可以使用bundle的方式来进行管理,比如kkgridview里就是把所需的图片文件全部放在一个bundle来管理的 .

    切记目前iOS中只允许使用bundle管理资源文件和国际化信息,不支持代码的打包。

    在xcode中只能够创建setting bundle,会默认创建一些配置文件,在xcode中无法直接删除,这也许不是我们需要的。

    那么如何使用最简单的方法创建一个bundle呢?

    1 创建一个文件夹

    2 将该文件夹重命名为a.bundle

    3 将a.bundle拖入到xcode中即可

    调用:

    - (UIImage *)imagesNamedFromCustomBundle:(NSString *)imgName
    
    {
        NSString *bundlePath=[[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"sources.bundle"];
        
        NSBundle *bundle=[NSBundle bundleWithPath:bundlePath];
        
        NSString *imagePath =[[bundle resourcePath] stringByAppendingPathComponent:imgName];
        return [UIImage imageWithContentsOfFile:imagePath];
    }
  • 相关阅读:
    java实习生面试
    使用vue可视化界面创建vue项目
    Git操作分支
    ECharts获取Json文件数据
    Java中字符串反转
    es6新增的API
    es5新增的数组的方法
    操作字符串的相关方法
    排序方法总结
    js内置对象-Array
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/6693124.html
Copyright © 2011-2022 走看看