Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
Hello,

I have been looking for the line of code that would turn the sectioned table view headers to appear translucent, heres a code snippet.

Code:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    self.tableView.sectionHeaderHeight = 40;
    NSString *title = nil;
    // Return a title or nil as appropriate for the section.
    
    switch (section) {
        case 0:
            title = @"Row 1";
            break;
        case 1:
            title = @"Row 2";
            break;
        case 2:
            title = @"Row 3";
            break;
        default:
            break;
    }
    
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 35)];
    
    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(1,3, tableView.bounds.size.width - 1,35)] autorelease];
    label.text = title;
    label.textColor = [UIColor blackColor];
    label.font = [UIFont fontWithName:@"Arial-BoldMT" size:14];
    label.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"section_bar_blue.png"]];;

    [v addSubview:label];
    //[UIColor colorWithPatternImage:[UIImage imageNamed:@"section_bar_green.png"]];;
    return v;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.