karim karim - 18 days ago 6
iOS Question

Transparent background for the Group Table Cell

For group table cell, I fall into this problem.

cell.backgroundColor=[UIColor clearColor]


make the cell bg black. It works for normal cell, not for group table cell.
I want to add some button, e.g. like the detail view of iPhone contact with transparent background.

Answer

If anybody face the problem, I got a solution, set a transparent view as a background view of the cell. Then it becomes totally transparent. Then you can add more view or customize the cell.

UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
            backView.backgroundColor = [UIColor clearColor];
            messageCell.backgroundView = backView;

            messageCell.contentView.layer.cornerRadius = 10.0;
            messageCell.contentView.layer.borderWidth = 1.0f;
            messageCell.contentView.layer.borderColor = [[Settings getInstance] colorFrameBorder].CGColor;
            messageCell.selectionStyle = UITableViewCellSelectionStyleNone;
            return messageCell;

This solution was quoted in one of the StackOverflow question, which I cant remember. I have also found that, its easy to add a transparent view in the table header or footer. The button down the contact details are probably added in a footer view.