【问题标题】:UITableView header/footer font colorUITableView 页眉/页脚字体颜色
【发布时间】:2011-05-03 12:20:09
【问题描述】:

当覆盖(组样式)表格视图的页眉/页脚时,页眉和页脚字体应使用什么颜色以确保页眉和页脚字体与标准页眉和页脚字体一致?

ie 标题是这样加载的:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        if(myHeaderView == nil) {
            [[NSBundle mainBundle] loadNibNamed: @"MyHeaderView"
                                          owner: self
                                        options: nil];
        }
        return myHeaderView;
}

【问题讨论】:

  • 同样的问题,但对于 iOS 7?

标签: iphone cocoa-touch ipad uikit


【解决方案1】:

来自discussion

这是 iOS 6 上 tableView 标头的UILabel 信息:

Plain
fontName: Helvetica-Bold
pointSize: 18.000000
textColor: UIDeviceWhiteColorSpace 1 1
shadowColor: UIDeviceWhiteColorSpace 0 0.44
shadowOffset: CGSize 0 1


Grouped
fontName: Helvetica-Bold
pointSize: 17.000000
textColor: UIDeviceRGBColorSpace 0.298039 0.337255 0.423529 1
shadowColor: UIDeviceWhiteColorSpace 1 1
shadowOffset: CGSize 0 1

至于plain style header的背景,是UIImage,而不是简单的backgroundColor。注意细微的垂直渐变。

希望对你有帮助

【讨论】:

  • 对于 Grouped tableView 页脚,除了字体是正常粗体(不是粗体)和磅为 15 之外,其他所有内容都与页脚相同。
  • "对于普通样式标题的背景,这是一个 UIImage,而不仅仅是一个 backgroundColor。注意微妙的垂直渐变。"实际上,所有标签都有透明的背景颜色(全 alpha)。渐变来自表格视图的背景。现在,iOS 中甚至为分组表视图提供了一个特殊的“颜色”渐变。 ;-)
  • 如何以编程方式将所有这些设置到我的 UILabel 的文本中?
  • 如果您不想自己输入,someone has done so here
  • 作为字节值的文本颜色分量是76、86、108。
【解决方案2】:

这对我有用(对于页脚),对标签的 CGFrame 及其 numberOfLines 进行了一些摆弄,它可能对您有用:

int height = [self tableView:table heightForFooterInSection:section];

UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, table.bounds.size.width - 20, height)] autorelease];
label.text              = [self tableView:table titleForFooterInSection:section];
label.textColor         = [UIColor colorWithRed:0.298 green:0.337 blue:0.423 alpha:1.000];
label.font              = [UIFont systemFontOfSize:15.0];
label.backgroundColor   = [UIColor clearColor];
label.shadowColor       = [UIColor whiteColor];
label.shadowOffset      = CGSizeMake(0, 1);
label.textAlignment     = UITextAlignmentCenter;
label.numberOfLines     = 2;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 2012-04-24
    • 1970-01-01
    • 2016-12-02
    • 2013-05-22
    相关资源
    最近更新 更多