Uitableview Swift VIEWFORHEADERIN部分不使用自定义颜色
我在tableView的Uitableview Swift VIEWFORHEADERIN部分不使用自定义颜色,uitableview,swift,uicolor,Uitableview,Swift,Uicolor,我在tableView的viewForHeaderInSection方法中遇到了非常奇怪的行为: func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 30.0 } func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView
viewForHeaderInSection
方法中遇到了非常奇怪的行为:
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 30.0
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let label = UILabel(frame: CGRectMake(10.0, 10.0, tableView.frame.size.width, 30.0)) // Doesn't care about x, y offset
label.text = "Results"
label.textColor = UIColor.blueColor()
label.backgroundColor = UIColor.orangeColor() // Not Working: UIColor(red: 88, green: 130, blue: 202, alpha: 1.0)
return label
}
CGRectMake
构造函数中选择了哪些值,我的标签都将始终粘贴在左上角textColor
和backgroundColor
属性正在使用标准的UIColor颜色,例如UIColor.blueColor()
,但在使用UIColor(红色:88,绿色:130,蓝色:202,alpha:1.0)等颜色时失败。
->根本不显示任何内容 let newRed = CGFloat(88)/255
let newGreen = CGFloat(130)/255
let newBlue = CGFloat(202)/255
self.init(red: newRed, green: newGreen, blue: newBlue, alpha: 1.0)
来自UIColor文档:颜色对象的红色组件,指定为0.0到1.0之间的值。你们太棒了!令人尴尬的错误。把UILabel放到UIView中,它就应该工作了。@yene:谢谢,我刚刚试过这个,它工作了