我有一个非常简单的问题(我希望如此)。如何将 UITableview 中的部分标题颜色从默认蓝色更改为黑色透明? 提前致谢。
最佳答案
这是一个老问题,但我认为答案需要更新。
此方法不涉及定义您自己的自定义 View 。
在 iOS 6 及更高版本中,您可以通过定义
轻松更改背景颜色和文本颜色
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section委托(delegate)方法。
例如:
- (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]; }
摘 self 在这里的帖子: https://happyteamlabs.com/blog/ios-how-to-customize-table-view-header-and-footer-colors/
关于iphone - 更改 UITableview 中节标题的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2389889/