Keep an NSArray of UIColor objects as an instance variable of your class (the view controller that acts as delegate/data source), say you call it sectionColors. You can initialize the colors in this array from values in your plist, or hard-code the colors.
Then, use this code:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *tempHeaderView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,44)]; // This changed: tempHeaderView.backgroundColor = [sectionColors objectAtIndex:section]; [tempHeaderView addSubView: tempHeaderLabel]; return tempHeaderView; // Use 'return [tempHeaderView autorelease];' in a non-ARC environment }
This is how you could initialize the array:
// Assuming your table has three sections (indices 0 through 2) UIColor* colorForSection0 = [UIColor colorwithRed:redValue0 green:greenValue0 blue:blueValue0 alpha:1.0]; // redValue0, etc. are floats between 0.0 and 1.0 that you can read from a .plist // Alternatively, store them as integers between 0 and 255, and divide them by 255.0 // and store on CGFloat variables before creating color. // ...Do the same for the other colors... // Now that you have the colors, create array and store in ivar 'sectionColors' sectionColors = [[NSArray alloc] initWithObjects: ColorforSection0, ColorForSection1, colorForSection2, nil];
(the code above should go inside the table view data source's initializer)