如何在iPhone的表格视图中插入png图像 [英] how to insert png image in table view for iphone

查看:60
本文介绍了如何在iPhone的表格视图中插入png图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在表格视图中显示小图像,但是我想将png作为表格视图的每个单元格的BG加载

i can show small image in table view but i want to load a png as a BG of each cells of my table view how to do that

   cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil && searching==NO) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
                //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        /*
        UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Live and LearnCell" ofType:@"png"]];
        cell.image = img;
        */

        //// FISRTS LABEL  
        cell.imageView.image = [UIImage imageNamed:@"TopCell.png"];

        mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(70.0, 5.0, 220.0, 15.0)] autorelease];

        mainLabel.tag = MAINLABEL_TAG;

    //  mainLabel.font = [UIFont systemFontOfSize:14.0];
        [mainLabel setFont:[UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]]];

        mainLabel.textAlignment = UITextAlignmentLeft;

        mainLabel.textColor = [UIColor whiteColor];
         mainLabel.highlightedTextColor = [UIColor greenColor];

    //mainLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;

        [cell.contentView addSubview:mainLabel];
}

如何将PNG作为BG添加到此单元格?

how to add PNG as BG to this cell??

推荐答案

cell.backgroundView = [[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]自动释放];

这篇关于如何在iPhone的表格视图中插入png图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆