我的tableview中有两个部分,我想为tableView的不同sectionHeaders设置不同的颜色,我该怎么做?
func tableView(tableView: UITableView!,titleForHeaderInSection section: Int) -> String! { if (section == 0) { return "Item1" } if (section == 1) { return "Item2" } }
解决方法
与Objective-C中的方式相同:提供带标签的自定义标题并更改其文本颜色
override func tableView(tableView: UITableView!,viewForHeaderInSection section: Int) -> UIView! { var label : UILabel = UILabel() if(section == 0){ label.text = "Item1" } else if (section == 1){ label.textColor = UIColor.orangeColor() label.text = "Item2" } return label }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。