2010-07-26 3 views
1

я могу показать маленькое изображение в виде таблицы, но я хочу, чтобы загрузить PNG как BG каждых клеток с моей точкой зрения таблицы, как это сделатькак вставить изображение PNG в виде таблицы для Iphone

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 к этой ячейке?

ответ

0

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

+0

спасибо большое 0 – ram

+0

эй, что если мне нужно объединить 2 изображения на let say top и bottm images только в 1 ячейке ??? – ram

+0

откройте новый вопрос с конкретными деталями. –

0

Посмотрите на backgroundView свойство UITableViewCell. Вы можете загрузить PNG в UIImageView и установить его в качестве фона вашей ячейки.

Если вы хотите установить фон своего UITableView, он также имеет свойство backgroundView.

+0

отлично для вас много пива – ram

Смежные вопросы