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

North Bronson

macrumors 6502
Original poster
Oct 31, 2007
395
1
San José
When you use Apple's free header views for your sections (and add text for a title), does anyone know what is going on behind the scenes? Is it just a regular UILabel?

The reason that I ask is because I had to write some custom section headers with my own labels. I made the labels with a clear background so that the textured table background shows through. It seems like my table isn't scrolling quite as fast as it used to.

Is there any other way to show that textured background behind my label while keeping the label opaque? Is this what is going on when you use Apple's section views?
 
When you use Apple's free header views for your sections (and add text for a title), does anyone know what is going on behind the scenes? Is it just a regular UILabel?

The reason that I ask is because I had to write some custom section headers with my own labels. I made the labels with a clear background so that the textured table background shows through. It seems like my table isn't scrolling quite as fast as it used to.

Is there any other way to show that textured background behind my label while keeping the label opaque? Is this what is going on when you use Apple's section views?
The 'Cells and Table-View Performance' section of the "Table View Programming Guide for iPhone OS" recommends using opaque subviews or you may impact the performance of your table view. This is probably what is happening with your section headers.

Depending on the characteristics of your textured background, you may be able to include a similar background into your section titles and those avoid the need for transparency.
 
Depending on the characteristics of your textured background, you may be able to include a similar background into your section titles and those avoid the need for transparency.

All that I want is the same blue-and-white lines that you see behind the normal Apple grouped tableview.
 
All that I want is the same blue-and-white lines that you see behind the normal Apple grouped tableview.
If you are using a Grouped Style table view and are already getting the blue-and-white lines then, wow, I don't think there should be any impact in using the tableView:titleForHeaderInSection: since that just returns an NSString that I'm pretty sure gets converted into a UILabel for the section titles.
 
If you are using a Grouped Style table view and are already getting the blue-and-white lines then, wow, I don't think there should be any impact in using the tableView:titleForHeaderInSection: since that just returns an NSString that I'm pretty sure gets converted into a UILabel for the section titles.

Well, I kind of wanted to display the title in two different fonts and with different justifications. I don't think titleForHeaderInSection would give me that much control.
 
So how do I actually implement a custom section header? subclass UITableView and override the drawRect method, using [self rectForSection:<num>] to figure out where to render it?

Specifically, I'm wondering if I can add a UIButton to one of my section headers - so I want not just to draw a button, but also to respond to clicks on it. Any ideas, is this possible?

Cheers, Alan
 
You could always set the background to your custom header labels rather than having them clear:

Code:
mylabel.backgroundColor = [UIColor groupTableViewBackgroundColor];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.