UITableView页眉/页脚字体颜色

时间:2011-05-03 12:20:10

标签: iphone cocoa-touch ipad uikit

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

ie 正在加载标题:

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

2 个答案:

答案 0 :(得分:42)

从此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

对于普通样式标题的背景,这是一个UIImage,而不仅仅是一个backgroundColor。注意细微的垂直渐变。

希望有所帮助

答案 1 :(得分: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;