Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uitableview 第一个tableview节的标题比其余部分大_Uitableview_Swift_Layout - Fatal编程技术网

Uitableview 第一个tableview节的标题比其余部分大

Uitableview 第一个tableview节的标题比其余部分大,uitableview,swift,layout,Uitableview,Swift,Layout,我正在制作自定义uitableview。但是,第一部分的标题比其他部分大 代码如下: func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { var header = UIView(frame: CGRectMake(0, 0, tableView.bounds.width, 30)) header.backgroundColor = UIColor(

我正在制作自定义uitableview。但是,第一部分的标题比其他部分大

代码如下:

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    var header = UIView(frame: CGRectMake(0, 0, tableView.bounds.width, 30))
    header.backgroundColor = UIColor(red: 223/255.0, green: 170/255.0, blue: 128/255.0, alpha: 1.0)

    return header

}

如何修复此问题?

试试这个

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 30.0
    }

您是否在您的代码中实现了
-tableView:heightForHeaderInSection:
?没有,我将尝试。我尝试了,效果很好,感谢您将在4分钟内选择您的答案(stack exchange不允许我立即选择它)