OC仿支付宝我的界面。

自已的视图下拉时,会出现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;

支付宝效果:
支付宝效果

我的效果:
我的效果

阅读 3k
2 个回答

已经换了另一种方式,去掉了原生NavigationBar,自己模拟了一个

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进