如何去除 UITableView 顶部的灰线 [英] How remove gray line on top UITableView

查看:68
本文介绍了如何去除 UITableView 顶部的灰线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初始化 UIViewController 代码:

Init UIViewController code:

    self.view.backgroundColor= [UIColor whiteColor];
    CGSize boundsSize = self.view.bounds.size;
    CGRect rectTableViewFrame = CGRectMake(0, 0, boundsSize.width, boundsSize.height - 64);
    UITableView* contentTableView = [[UITableView alloc] initWithFrame:rectTableViewFrame];

    contentTableView.backgroundColor = [UIColor clearColor];
    contentTableView.separatorColor = [UIColor clearColor];
    contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

接下来添加 UITableView 自定义视图(标题):

Next add in UITableView custom view (header):

    CustomView* customView = [[CustomView alloc] init];
    CGRect customViewFrame = customView.frame;
    customViewFrame.origin.y = - customView.size.height;
    customView.frame = customViewFrame;

    contentTableView.contentOffset = CGPointMake(0, customViewFrame.origin.y);
    contentTableView.contentInset = UIEdgeInsetsMake(customViewFrame.frame.size.height, 0, 0, 0);
    [contentTableView addSubview: customView];

问题:滚动contentTableView顶部customView时有一条灰线...如何删除?我不使用方法:

Problem: When scroll contentTableView the top customView there is a gray line... How delete this? I don't use methods:

    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

但是如果使用带有白色背景颜色的简单视图,则没有线条.

But if use simple view with white background color there is no line.

推荐答案

您可以尝试设置无线样式,例如:

you can try to set no-line style like:

contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

并在UITableViewCell底部添加一条灰线.

and add a gray line at the bottom of you UITableViewCell.

这篇关于如何去除 UITableView 顶部的灰线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆