pathForResource:imgPath

+(id)createImageView:(CGRect)frame forPath:(NSString *)imgPath{

    

    UIImageView *imageView = [[[UIImageView alloc] init] autorelease];

    

    imageView.frame = frame;

    

    if (imgPath != nil) {

//        UIImage *img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imgPath ofType:@"png"]];

        UIImage *img = [UIImage imageNamed:imgPath]; //CYY 发现上边那种方法只能读取到单倍图

        imageView.image = img;

    }

    

    return imageView;

    

}

你可能感兴趣的:(pathForResource:imgPath)