bundle文件簡(jiǎn)單理解就是一個(gè)專門放置、管理資源文件一個(gè)靜態(tài)包,不參與項(xiàng)目的編譯。
1、bundle文件的創(chuàng)建:
右鍵 -> New File -> iOS-> Resource -> Settings Bundle -> 為這個(gè)bundle文件起個(gè)名字 ->create -> 將你的資源文件拖進(jìn)去 (ok);
2、bundle文件的使用:
我這里拖進(jìn)去的是一個(gè)adsImage圖片資源文件夾

99BC132D-EFC6-459F-9288-469C49667864.png
獲取圖片資源:
bundle文件路徑:
NSString * bundlePath = [[NSBundle mainBundle] pathForResource:@"AdvertiseImage" ofType:@"bundle"];
adsImage文件路徑:
NSString * adsImagePath = [bundlePath stringByAppendingPathComponent:@"adsImage"];
圖片資源:
UIImage *image = [UIImage imageWithContentsOfFile:[adsImagePath stringByAppendingPathComponent:@"ads1.png"]];
就這么簡(jiǎn)單.....