关于静态库添加图片资源的解决方案
2016-05-04 19:38
387 查看
封装.a 静态库
剩下的操作和动态更新差不多!可以参考我之前的一篇文章热更新FrameWork
创建bundle
只需要将图片资源放入一个文件夹如:imageSource
然后把后缀改成.bundle即可
使用资源图片
拼接路径
这里得到的就是你需要的图片资源
将需要的头文件添加到publicGroup 内
分别声称release 和debug 两个版本的.a 文件方便调试和 真机使用
将两个版本.a 合并
看下 你会发现1 就是lipo -create ……后的Path
2 就是1.a 空之后的Path
3 就是 -output 之后的Path
也就是 你需的合并后的.a 库
将.a 和bundle 同时放入同一工程一个文件下
.a需要用到的图片资源就会去.bundle 中找
这样就可以了!
剩下的操作和动态更新差不多!可以参考我之前的一篇文章热更新FrameWork
创建bundle
只需要将图片资源放入一个文件夹如:imageSource
然后把后缀改成.bundle即可
使用资源图片
$ NSBundle *imageSourceBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"imageSource" ofType:@"bundle"]]
拼接路径
$ if (retainFllow5) {// 判断加载几倍图 imageSuffix = [NSString stringWithFormat:@"%d@2x",n]; } else { imageSuffix = [NSString stringWithFormat:@"%d@3x",n]; } $ NSString *mosaic = [NSString stringWithFormat:@"%@%@", imagePrefix, imageSuffix]; $ NSString *imageSource = [imageSourceBundle pathForResource:mosaic ofType:@"png"];
这里得到的就是你需要的图片资源
$ [UIImage imageWithContentsOfFile:imageSource]
将需要的头文件添加到publicGroup 内
分别声称release 和debug 两个版本的.a 文件方便调试和 真机使用
将两个版本.a 合并
$ lipo -create /Users/chenwei/Desktop/XXX/debug/libPeopleKeybord.a /Users/chenwei/Desktop/XXX/release/libPeopleKeybord.a -output /Users/chenwei/Desktop/XXX/libPeopleKeybord.a
看下 你会发现1 就是lipo -create ……后的Path
2 就是1.a 空之后的Path
3 就是 -output 之后的Path
也就是 你需的合并后的.a 库
将.a 和bundle 同时放入同一工程一个文件下
.a需要用到的图片资源就会去.bundle 中找
这样就可以了!
相关文章推荐
- Patrol 7 架构下?的处理方法
- 按右键另存图片只能存BMP
- photoshop去除图片上的水印
- 中病毒后常用的解决方法病毒终极解决方案
- upload上传单张图片
- 图片引发的溢出危机(图)
- QQ尾巴 InfoMs.Ime 解决方案
- C#实现把彩色图片灰度化代码分享
- C#将图片和字节流互相转换并显示到页面上
- C#监控文件夹并自动给图片文件打水印的方法
- IE对CSS样式表的限制分析与解决方案
- 纯CSS实现的当鼠标移上图片添加阴影效果代码
- 如何使用C#从word文档中提取图片
- C#实现打开画图的同时载入图片、最大化显示画图窗体的方法
- C#图片添加水印的实现代码
- 随鼠标移动的图片或文字特效代码
- CSS 图片横向排列实现代码
- C#实现将Email地址转成图片显示的方法
- C#实现图片加相框的方法
- 开源MySQL高效数据仓库解决方案:Infobright详细介绍