2010-10-19 35 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感謝人們貢獻自己的知識