IOS 开发Framework如何使用简单的使用图片资源的两种方式

这里是demo图:

IOS 开发Framework如何使用简单的使用图片资源的两种方式

1)使用Bundle文件方式,支持所有文件格式。

     1.1建立一个文件夹,Support。修改扩展名为Support.bundle

    1.2右键显示所有,打开这个文件夹,放入图片,当然可以是其他文件。

2)Assert.xcassets方式。

   添加文件选择Assets.xcassets 文件,选择确定,默认名称Media.xcasset;

 

=======================

代码:

    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    //建立一个文件见,修改为Support.boundle,拖到里面去了,最后显示内容,放入文件。,放到工程里。
    UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"Support.bundle/%@",@"logo.png"] inBundle:bundle compatibleWithTraitCollection:nil];

代码2:

  

     UIImage *img = [UIImage imageNamed:@"ic_play"
                               inBundle:bundle compatibleWithTraitCollection:nil];