在 viewDidLayoutSubViews() 中设定 headerView 的高度 override func viewDidLoad() { self.headerView = (Bundle.main.loadNibNamed("CreateOrderTableHeaderView", owner: self, options: nil)![0] as? CreateOrderTableHeaderView) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() sizeHeaderToFit() } func sizeHeaderToFit() { if let