UIImage不一样环境下的几种建立方式

 

        //UIImage就是一个图片  本身不能显示  必须依托其余空间显示图片

    //建立的经常使用3种方法内存

    //1 图片较小可以使用此种方法 此方法建立的图片会一直驻留在内存中it

    UIImage * img1=[UIImage imageNamed:@"1.png"];file

    

    //2 图片较大可使用此方法  从文件中获取一个图片方法

   UIImage *img2=[[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"2" ofType:@"png"]];im

    

    //3 获取路径 把图片读取到DATA中 在把DATA的内容给图片设置上img

    NSString *filePath=[[NSBundle mainBundle]pathForResource:@"3" ofType:@"png"];文件

    

    NSData *data=[[NSData alloc]initWithContentsOfFile:filePath];data

    

    UIImage *img3=[[UIImage alloc]initWithData:data];path

相关文章
相关标签/搜索