How to make an iOS asset bundle?

前端 未结 7 582
谎友^
谎友^ 2020-12-02 05:37

I saw a custom asset bundle in an iOS project I evaluated, so at least I know it\'s possible.

My issue is that I\'m using a CATiledLayer with about 22,000 tiles for

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 05:52

    How to create a bundle

    1. Create a folder in finder.
    2. Add files to the folder
    3. Rename the folder so that its extension is .bundle (e.g. "New folder" -> "BundleName.bundle")

    PS: You can at any time right click the folder and hit "Show package content" in order to add, remove or modify any of the files.

    How to add the bundle to Xcode

    1. Drag it into Xcode

    How to use the bundle

    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"BundleName" ofType:@"bundle"];
    NSBundle *bundle = [NSBundle bundleWithPath:bundlePath]; 
    NSString *resource = [bundle pathForResource:@"fileName" ofType:@"fileType"];
    

    (Replace BundleName, fileName and fileType with appropriate names)

提交回复
热议问题