我在tableview的每个部分都有一个UILabel。我在标签的末尾贴了这条线,这是来自iPhone 6.我之前在iPhone 5上遇到过它,并设法通过改变UILabel的宽度使其消失。
这里是viewForHeaderInSection上的代码:
let view = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, 30))
view.backgroundColor = UIColor(red: 248/255, green: 247/255, blue: 243/255, alpha: 1.0)
let label = UILabel(frame: CGRectMake((self.view.bounds.width - (self.view.bounds.width * 0.4)) / 2, 0, self.view.bounds.width * 0.4, 25))
label.backgroundColor = UIColor(red: 248/255, green: 247/255, blue: 243/255, alpha: 1.0)
label.textColor = UIColor(red: 163/255, green: 144/255, blue: 99/255, alpha: 1.0)
label.textAlignment = .Center
label.text = "YOUR TITLE HERE"
let line1 = UIView(frame: CGRectMake((self.view.bounds.width - (self.view.bounds.width * 0.8)) / 2, 13, self.view.bounds.width * 0.8, 1))
line1.backgroundColor = UIColor(red: 163/255, green: 144/255, blue: 99/255, alpha: 1.0)
view.addSubview(line1) // Adds the line first
view.addSubview(label) // Then the label on top of the line for the look.
return view