ios - 如何在 UITableView 的部分标题中设置字体颜色?

标签 ios uitableview colors header sectionheader

tableView:viewForHeaderInSection: 是调整 UITableViewCell 标题部分字体颜色的最佳方式吗?

我想简单地调整字体颜色(理想情况下),而不必定义 UIView。我特别不愿意使用上述方法,因为过去对齐节标题给我带来了麻烦。

最佳答案

tableView:viewForHeaderInSection:返回一个 UIView。您必须创建一个 UIView,将 UILabel 添加到 UIView 中,并调整 UILabel 的字体。

例如:

{
UIView *headerView = [[[UIView alloc]   
initWithFrame:CGRectMake(0,0,self.view.frame.size.width, 30)] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:headerView.frame];
label.font = [UIFont systemOfFontWithSize:12];
....
return headerView;
}

关于ios - 如何在 UITableView 的部分标题中设置字体颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8483001/

相关文章:

ios - 由于信号 : Segmentation fault: 11 swift 3,命令失败

ios - 声明我的 CellClass 以扩展到 UITableViewCell?

ios - 基于 UITableview 单元格选择和取消选择,快速添加和删除项目到数组中

javascript - 如何确保文本/链接的 CSS 不透明度更改不会更改 Firefox/Windows 中的颜色值?

colors - 使用 ImageMagick 去除图像中除黑色以外的所有颜色?

python - 如何在seaborn中从RGB颜色列表构建颜色图?

ios - 单击屏幕左边缘的按钮时不突出显示,但触发事件

ios - Swift 函数无法尝试从 rest 服务获取 JSON 数组并转换为 swift 对象

iphone - tableView 滚动时 UITableView 委托(delegate)操作?

ios - UITableview 原型(prototype)单元格未正确填充