自已的视图下拉时,会出现tableView的背景色,和tableView.headerView与Navbar的颜色不一样。
但如果tableView的背景色设为和Navbar的一样,那tableView下面的section的颜色又很难看了。
上代码:
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KYScreenWidth, KYScreenHeight) style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundColor = KYCommonBgColor;
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
tableView.sectionHeaderHeight = 20;
tableView.sectionFooterHeight = 0;
tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
[self.view addSubview:tableView];
_tableView = tableView;
UIImageView *backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.ky_width, 80)];
backView.image = [UIImage createImageWithColor:KYNavbarColor];
backView.userInteractionEnabled = YES;
_tableView.tableHeaderView = backView;
支付宝效果:
我的效果:
已经换了另一种方式,去掉了原生NavigationBar,自己模拟了一个