tags:

views:

90

answers:

3

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];
}

how to add PNG as BG to this cell??

A: 

cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]] autorelease];

Ortwin Gentz
thanks a lot ;0
ram
hey what if i have to merge 2 images on lets say top and bottm images in 1 cell only???
ram
open a new question with specific details.
Ortwin Gentz
A: 

Have a look at the backgroundView property of UITableViewCell. You can load your PNG into a UIImageView and set it as the background of your cell.

If you want to set the background of your UITableView, it also has a backgroundView property.

Chris Doble
perfect thaks a lot beer for you
ram
A: 

its working :-)

ram