Translucent Sectioned Table View Header

Discussion in 'iOS Programming' started by ljg93, Jul 30, 2011.

  1. macrumors member

    Joined:
    Mar 13, 2011
    #1
    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;
    }
    
    
     

Share This Page