Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView header/footer font color

When overriding the header/footer of a (group styled) table view, what colour should be used for the header and footer fonts to ensure the header and footer fonts are consistent with the standard header and footer fonts?

ie The header is being loaded like this:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        if(myHeaderView == nil) {
            [[NSBundle mainBundle] loadNibNamed: @"MyHeaderView"
                                          owner: self
                                        options: nil];
        }
        return myHeaderView;
}
like image 251
Jay Avatar asked May 03 '11 12:05

Jay


People also ask

What is header and footer in UITableView?

A reusable view that you place at the top or bottom of a table section to display additional information for that section. Use UITableViewHeaderFooterView objects to manage the header and footer content of your table's sections efficiently. A header-footer view is a reusable view that you can subclass or use as is.

How do I set the background color on uitableviewheaderfooterview?

In the “Table Section Header” view, make sure the background color is default. This is to avoid the warning Setting the background color on UITableViewHeaderFooterView has been deprecated. Add a View. This is a container and MUST be there to contain all the other subviews. Add the title UILabel, and connect this to the IBOutlet in the class file.

How do I add a footer view to the header?

If you build and run the app you should see the following: The footer is basically the same as the header but there can be a catch if you only want a footer view. To only have a footer view, you will need to add a prototype cell, that will allow you to add a footer view below the cell.

How to add a header to a Tableview in Interface Builder?

Ok, if you build and run the app it should look like this: Adding a header to the tableview in Interface Builder is easy, once you have your tableview drag a new view over the tableview towards the top, a blue line should appear, when it does you can place the view. See the below gif:


2 Answers

From this discussion

Here's the UILabel info for tableView headers on iOS 6:

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

As for the background of the plain style header, that's a UIImage, not simply a backgroundColor. Notice the subtle vertical gradient.

hope it helps

like image 198
visakh7 Avatar answered Oct 03 '22 15:10

visakh7


This works for me (for the footer), with some fiddling of the CGFrame of the label, and its numberOfLines it might work for you to:

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;
like image 27
MrHus Avatar answered Oct 03 '22 15:10

MrHus