When we write the project, we need to add a lot of pictures, this time in addition to the X-code-->assets file to add pictures, you can also add the program bundle, so that
The project looks relatively neat, but also looks more professional, the following is the process of building the program bundle:
1. Create a new folder on the desktop
2, the folder naming format is "Xxxx.bundle", and then return to the
In this case, a program bundle is finished, inside can add audio and video, pictures and other files! Added to the project can be used directly!
How to use:
UILabel *la = [[UILabel alloc] Initwithframe:cgrectmake (a); @" XXX " ; *image_url = [[[NSBundle Mainbundle] ResourcePath] stringbyappendingpathcomponent:@ "images.bundle/ images/filename "]; = [Uicolor colorwithpatternimage:[uiimage Imagewithcontentsoffile:image_url]];
You can also use categories to implement:
-(uiimage*) Imagesnamedfromcustombundle: (NSString *) name { *main_images_dir_path = [[[NSBundle] Mainbundle] ResourcePath] stringbyappendingpathcomponent:@ "images.bundle/images"] ; // Nsassert (Main_images_dir_path, @ "Main_images_dir_path is null"); NSString *image_path = [Main_images_dir_path stringbyappendingpathcomponent:name]; return [UIImage Imagewithcontentsoffile:image_path];
This can be very convenient to use!
Development of iOS--manufacture of bundle program bundles