3
votes

The cells of my UITableView are grouped text fields. When I run my code on the emulator, I get this:

Grouped text fields and button

As you can see there is a gray area around the text fields while the background of the UITableView and the button is white. Is it possible to remove, or make invisible, the gray border (not the separator or the frame but the area) around the grouped cells? If so, how can I do that?

Update: Background color is working on iPhone but not on iPad. I'm working on iPad.

I fixed the problem. Solution:

UIView *clearView = [[UIView alloc] initWithFrame:[myTableView bounds]];
clearView.backgroundColor = [UIColor clearColor];
myTableView.backgroundView = clearView;
[clearView release];

Since setting the background on the xib file is not working, I did it programatically. Here, myTableView is the tableView object on the xib. As you can see, I replaced the background view with a view that has a clear color (transparent). The desired effect is achieved.

4

4 Answers

6
votes

If you mean the table view's background colour you can do it in the nib

enter image description here

Making the background colour clear just means you have to be aware of what is behind the table - as you will then see that!

If you mean the gray lined border You have to do it in code.. So in say the viewDidLoad method of the table view's owning class.

self.tableView.separatorColor = [UIColor clearColor];
1
votes

Set the background color of the table view to clear color.

Like this

myTableView.backgroundColor = [UIColor clearColor];

myTableView.opaque = NO;
myTableView.backgroundView = nil;
0
votes

Declare your table as following to get plain tableview.

yourTable = [[UITableView alloc] initWithFrame:CGRectMake(0,0, 320, 460) style:UITableViewStylePlain];
0
votes

Yeah friends, Nothing to do extra, just set your table view background to nil.

yourTableView.backgroundView = nil;

Enjoy :)