[IOS] 简单的bundle创建

来源:互联网 发布:淘宝直通车价格查询 编辑:程序博客网 时间:2024/06/04 19:35
1)创建一个bundle

(2)修改属性设置

(3)编译得到bundle
(4)将bundle拖动到app的supporting files里

(5)引用

NSString *bundlePath = [[NSBundle mainBundle].resourcePathstringByAppendingPathComponent:@"DemoBundle.bundle"];

    NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];

    UIImage *(^getBundleImage)(NSString *) = ^(NSString *n) {

        return [UIImage imageWithContentsOfFile:[bundle pathForResource:nofType:@"png"]];

    };

    UIImage *myImg = getBundleImage(@"gt_ac_down");

    NSLog(@"%@",myImg);

    UIImageView *iv = [[UIImageView alloc] initWithImage:myImg];

    [self.view addSubview:iv];

0 0
原创粉丝点击