简体   繁体   中英

iPhone - UITableView with a clear background when grouped?

I have several TableViews in my current application and I'd like to have a background image behind them.

However I'm finding it impossible to achieve this at the minute.

I have spent 2 days searching the web for a solution yet any solution I find is not 100% correct.

I have tried setting the background color of the table view to the image and this had some positives, the image appeared behind the table view, however it also appeared in the background of ever table cell also and looked terrible.

So I also tried by setting the background color of the table view to clear color, in code as I read doing this in IB doesn't work which seemed to be the case. And I then put a UIImageView behind the table view.

However this simply displays the table view with a white background and the image is no where to be seen.

Can anyone point me in the right direction as to how to do this properly?

Try this

UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cloud.png"] ];
    self.tableView.backgroundView = imageView;

    [imageView release];

to clear background use

self.tableview.backgroundcolor = [uicolor clearcolor];

Set the image as background to the table view (as you did) and set another color as background for your table view cells.

Try this in - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath :

  cell.backgroundColor = [UIColor greenColor];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM