potremmo aver necessità di personalizzare la grafica dei titoli delle sezioni, come California o New York dell'esempio qui sotto. When we use a UITableView style Grouped we may need to customize the layout of section titles, such as California or New York the example below.

To do so, please use the following code, placing it in the delegate, ie the class that responds to the protocol UITableViewDelegate :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | / / I return my custom View, in this case an object / / Type UILabel UIView * ) tableView : ( UITableView * ) tableView - (UIView *) tableView: (UITableView *) tableView NSInteger ) section { viewForHeaderInSection: (NSInteger) section { [ [ [ UILabel alloc ] initWithFrame : CGRectZero ] autorelease ] ; UILabel * label = [[[UILabel alloc] initWithFrame: CGRectZero] autorelease]; UIFont boldSystemFontOfSize : 20 ] ; label.font = [UIFont boldSystemFontOfSize: 20]; label.textAlignment = UITextAlignmentCenter; UIColor blackColor ] ; label.shadowColor = [UIColor blackColor]; 1 , 1 ) ; label.shadowOffset CGSizeMake = (1, 1); "Sezione" ; // Sostituire con un array come al solito Label.Text @ = "Section", / / Replace with an array as usual UIColor whiteColor ] ; label.textColor = [UIColor whiteColor]; UIColor clearColor ] ; label.backgroundColor = [UIColor clearColor]; ; label.opaque = NO; return label; } / / We must also support this message will not work CGFloat ) tableView : ( UITableView * ) tableView - (CGFloat) tableView: (UITableView *) tableView NSInteger ) section { heightForHeaderInSection: (NSInteger) section { ; return 44; } |
It is also important to include heightForHeaderInSection , it will not work.
Notes of Interest
o UIImageView , ho utilizzato per inizializzare il frame CGRectZero che corrisponde a CGRectMake(0,0,0,0) . In the creation of our UILabel , that wanting could also be a more complex object such as a UIView or UIImageView , I used to initialize the frame CGRectZero which corresponds to CGRectMake(0,0,0,0) .






Latest Comments
GM : Hi, sorry to resurrect an old post but I hope you can give me a hand. How do I, with this method, ...
Giovambattista Fazioli : @ Fabio: a post from the past! I would recommend using the most convenient features of tabs now ...
Fabio : Hello, searching the web I found this article to create your javascript tab strip with php and css, but ...
Miriam : What do you think of Disqus? I am using it and I love it.
Giovambattista Fazioli : @ Nik: I'm happy! Good luck then!