Development of iOS--manufacture of bundle program bundles

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.