我正在设计 UITableView 的样式应用内设置工具包 http://InAppSettingsKit并想要更改标题的颜色:
标签Without title
and Text Field
应该是白色的。如何才能做到这一点?
Thanks.
这是一个老问题,但我认为答案需要更新。
此方法不涉及定义和创建您自己的自定义视图。
在 iOS 6 及更高版本中,您可以通过定义
-(void)tableView:(UITableView *)tableView
willDisplayHeaderView:(UIView *)view
forSection:(NSInteger)
委托方法。
例如:
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
// Background color
view.tintColor = [UIColor blackColor];
// Text Color
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor whiteColor]];
// Another way to set the background color
// Note: does not preserve gradient effect of original header
// header.contentView.backgroundColor = [UIColor blackColor];
}
摘自我在这里的帖子:https://happyteamlabs.com/blog/ios-how-to-customize-table-view-header-and-footer-colors/ https://happyteamlabs.com/blog/ios-how-to-customize-table-view-header-and-footer-colors/
斯威夫特 5.0:
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
if let header = view as? UITableViewHeaderFooterView {
header.textLabel?.textColor = .white
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)