Reputation: 505
I created a tableView like the picture. There is space between section and cell. So the color of the space is the tableview default color.
To remove the extra lines on the tableview, I added a UIVIew() to tableView?.tableFooterView
.
let footerView = UIView()
self.tableView?.tableFooterView = footerView
I want to let the UIView's color same in the "target color" ont the picture.
I have tried like below, but it doesn't work.
let footerView = UIView()
footerView.backgroundColor = UIColor.black
footerView.tintColor = UIColor.black
self.tableView?.tableFooterView = footerView
What should I do ? Thanks!
Upvotes: 2
Views: 2923
Reputation: 8443
There is an another solution if you want to use different color for the tableview footer.
Swift 4
tableView.tableFooterView = UIView()
let screenRect = view.bounds;
let screenWidth = screenRect.size.width;
let screenHeight = screenRect.size.height;
let footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT))
let footerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: screenWidth, height: screenHeight - footerHeight))
footerView.backgroundColor = UIColor.darkGray // or your custom color
tableView.tableFooterView?.addSubview(footerView)
Objective-C
self.tableView.tableFooterView = [[UIView alloc] init];
CGRect screenRect = self.view.bounds;
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
CGFloat footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT));
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, screenWidth, screenHeight - footerHeight)];
footerView.backgroundColor = [UIColor darkGrayColor]; // or your custom color
[self.tableView.tableFooterView addSubview:footerView];
Upvotes: 0
Reputation: 72420
Try to Set the tableView
's backgroundColor
for that.
self.tableView?.backgroundColor = UIColor.white //Or color that you want
Upvotes: 4