iOS图片优化加载本地图片

2019-06-06  本文已影响0人  z_z
          UIImageView *imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];;
            //低效
            imageV.image = [UIImage imageNamed:@"图片.png"];
            
            //高效
            NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
            NSString *filePath = [resourcePath stringByAppendingPathComponent:@"图片.png"];
            UIImage *image = [UIImage imageWithContentsOfFile:filePath];
            imageV.image = image;
            
            [self.view addSubview:imageV];
上一篇下一篇

猜你喜欢

热点阅读