UIImageView设置图片的三种方式

//初始化

UIImageView  *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 120, 120)];


//需要设置图片 UIImage


第一种:[imageView setImage:[UIImage imageNamed:@"1.jpeg"]];


//第二种:
NSString *filePath=[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpeg"];
UIImage *images=[UIImage imageWithContentsOfFile:filePath];
//[imageView setImage:images]; 


//第三种:
NSData *data=[NSData dataWithContentsOfFile:filePath];
UIImage *image2=[UIImage imageWithData:data];

[imageView setImage:image2];

posted @ 2014-03-14 14:13  曈曈7添  阅读(1324)  评论(0)    收藏  举报