2010-10-19 39 views

回答

0

不要ü想设置背景图片为您的表或在UITableView的 单个细胞如果是用于设置背景图片,然后执行以下操作:


UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background.png" ofType:nil]]; 
UIColor *bgColor = [[UIColor alloc] initWithPatternImage:bgImage]; self.view.backgroundColor = bgColor;  
[tableName setBackgroundColor:[UIColor clearColor]]; 

其中tablename是你的UITableView的名称

如果你想设置背景图片的UITableView单元格,然后执行以下操作:


cell.backgroundColor = [UIColor clearColor]; 
UIImageView *cellBG_tap = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image.png" ofType:nil]]]; 
cell.backgroundView = cellBG_tap; 
[cellBG_tap release]; 

+1

在设置单元格的backgroundColor前设置cell.backgroundColor = [UIColor clearColor] – Swapna 2010-10-19 11:07:44

+0

@ swapna谢谢 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath :(NSIndexPath *)indexPath {cell_textLabel.font = [UIFont systemFontOfSize:20.0]; \t cell.detailTextLabel.textColor = [UIColor whiteColor]; \t cell.detailTextLabel.font = [UIFont systemFontOfSize:15.0]; \t cell.textLabel.backgroundColor = [UIColor clearColor]; \t cell.detailTextLabel.backgroundColor = [UIColor clearColor]; \t cell.imageView.image = [UIImage imageNamed:@“Sapphire Square.gif”]; } - 用于以上代码工作。谢谢所有 – 2010-10-19 12:22:01

0

设置在小区的一类,然后用CSS把背景图像,如下图所示:

<table class="myTable"> 
<tr> 
    <td class="myCell"></td> 
</tr> 
</table> 

<style> 
    .myCell { 
    background: url(my_image.gif) 
    } 
</style> 
+0

很确定@kiran意味着使用UITableViewCell而不是网页。 – Jordan 2010-10-19 06:47:57

+0

这个问题在“iPhone”下标记,而不是HTML或CSS。 – 2010-10-19 06:48:09

+0

我的不好。应该更仔细地红色。 – 2010-10-19 06:48:47

0

一种方法是修改的UITableViewCell的内容查看。例如:

//Add custom objects to the cell in here! 
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.jpg"]]; 

imageView.center = CGPointMake(310, 48); 
[cell.contentView addSubview:imageView]; 
[email protected]"test"; 
0

设定背景图片

UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yourImage.png"]]; 
    [cell setBackgroundView:img]; 
0
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 
    cell.textLabel.font =[UIFont systemFontOfSize:20.0]; 
    cell.detailTextLabel.textColor=[UIColor whiteColor]; 
    cell.detailTextLabel.font = [UIFont systemFontOfSize:15.0]; 
    cell.textLabel.backgroundColor = [UIColor clearColor]; 
    cell.detailTextLabel.backgroundColor = [UIColor clearColor]; 
    cell.imageView.image = [UIImage imageNamed:@"Square.gif"]; 

} 
在表视图数据源

cellForRowAtIndexPath 
if (indexPath.row%2==0) { 
UIImageView *img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"image..."]]; 
cell.backgroundView=img; 
[img release]; 

我用这它的工作

.... @all感谢人们贡献自己的知识