UITableViewCell清晰背景 - 分组UITableView [英] UITableViewCell clear background - Grouped UITableView

查看:111
本文介绍了UITableViewCell清晰背景 - 分组UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在分组表格中显示我的数据,如下所示:

I am trying to display my data in a grouped table as below :

正如您所见,我已通过在 viewDidLoad中编写以下代码来清除表格的背景视图

As you can see I have cleared the background view for the table by writing the following code in viewDidLoad :

customerTable.backgroundView = nil;  

同样在我的 xib 中,我已经清除了我桌子的背景。

Also in my xib I have cleared the background of my table.

cellForRowAtIndexPath 中,我为每个表格单元格设置了背景颜色。

In cellForRowAtIndexPath I have set the background color for each table cell.

cell.backgroundColor = [UIColor colorWithRed:255.0/255 green:235.0/255 blue:178.0/255 alpha:1];  

结果我获得了上述输出。

As a result I am getting the above output.

问题

我面临的问题是黑角我进入每个细胞。我知道它与细胞的背景有关,但没有什么对我有用。我还尝试清除单元格编写以下代码行的背景:

Problem I am facing is the black corners I am getting in every cell. I know it has something to do with background of the cell but nothing is working for me. I also tried to clear the background of cell writing the following code line :

    cell.backgroundView = nil;  

有人可以帮助我摆脱这些黑角吗?

Can someone help me to get rid of these black corners?

谢谢,

Nitish

Thanks,
Nitish

推荐答案

试试吧:

将单元格背景视图设置为YourcellImage&单元格背景颜色以清除颜色。

Set the cell background view to YourcellImage & cells background color to clear color.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath             
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

        [cell setBackgroundColor:[UIColor clearColor]];
        UIImage *backgroundImage = nil;
        UIImageView *backgroundView = nil;
        backgroundImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"YourYellowCellImage"ofType:@"png"]];
        backgroundView = [[UIImageView alloc]initWithImage:backgroundImage];
        backgroundView.frame = CGRectMake(0, 0, 600, 80); // Over here give your cell size
        cell.backgroundColor = [UIColor clearColor];
        cell.backgroundView =backgroundView;

        [backgroundView release];   
   }
   //Over your set your Label Value    
   return cell;
}

这篇关于UITableViewCell清晰背景 - 分组UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆