viewForHeaderInSection drawing a background but only if the view is at the top of the screen
My table view controller implements the viewForHeaderInSection function to return the section labels in a custom font.
Currently we use transparent background but that doesn't look good if the cells start scrolling behind the header view.
I want to draw a transparent-to-white gradient for the header view but only for the one stuck at the top.
Obviously if(section==0)
would not work.
开发者_如何学CIs there a trick for this?
sometimes it's better to think for a second before posting to stack overflow. Here is the solution I found for the record. I hope it helps somebody.
NSArray * visibleIndexes = [tableView indexPathsForVisibleRows];
NSIndexPath * firstVisibleIndex = [visibleIndexes objectAtIndex:0];
if (section == firstVisibleIndex.section) {
// configure the header at the top
}
else {
// configure other headers
}
精彩评论