These code lines below will show how to change background color, text, font name, font size in UITableView section header when you’re building iPhone applications.
You may need to change height of UITableView Section Header to fit with the customization:
self.tableView.sectionHeaderHeight = 40; |
And add this function:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { NSString *title = nil; // Return a title or nil as appropriate for the section. switch (section) { case 0: title = @"iPhone Apps Development"; break; case SPENDING_LIST: title = @"Android Apps Development"; break; default: break; } UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)]; [v setBackgroundColor:[UIColor blackColor]]; UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10,3, tableView.bounds.size.width - 10,40)] autorelease]; label.text = title; label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.60]; label.font = [UIFont fontWithName:@"Arial-BoldMT" size:14]; label.backgroundColor = [UIColor clearColor]; [v addSubview:label]; return v; } |
Note: you should replace [UIColor blackColor] with any UIColor you would like. You may also wish to adjust dimenstions of UIView and textColor, font, size of the UILabel.