IOS

bundle的创建,图片资源,xib资源的调用

2019-08-23  本文已影响0人  偷的浮生整日闲

一.创建bundle

(1)Targes中添加bundle


image.png
image.png

(2)bundle设置
在target中选择新建的bundle


image.png

设置如下:

二.生成bundle

(1)将资源文件拖进左侧文件夹

image.png
(2)command+B生成xxxx.bundle

三.图片资源,xib资源的调用

图片调用:

UIImage *image=[UIImage imageNamed:@"auth.bundle/iconxxx"]

xib使用:

NSString *path = [[NSBundle mainBundle] pathForResource:@"auth" ofType:@"bundle"];

NSBundle *SDKBundle = [NSBundle bundleWithPath:path];

TouchIDViewController *vc = [[TouchIDViewController alloc] initWithNibName:@"TouchIDViewController" bundle:SDKBundle];
//TouchIDViewController是xib文件对应的Controller

注⚠️:图片资源的三种分辨率(@1X,@2X,@3X)最好都齐全,不要缺失,亲测缺失了调用时会显示不出来
上一篇下一篇

猜你喜欢

热点阅读