开发者

How to change UITableViewController (Grouped) text color?

Quick question:

How can i change the label text color of the section i have in a UITableViewController, grouped style? EDIT:

Example

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSI开发者_如何学Pythonnteger)section{


    switch (section) {
        case 0:
            return @"A";
            break;
        case 1:
            return @"B";
            break;
        case 2:
            return @"C";
            break;
        default:
            return nil;
            break;


    }
   }

I want "A", "B", "C", to be white. Suggestions?


I don't think you can edit your title color / size of your section. This was mentioned in the apple forums.

What you can do is - Implement your own label / view for the section headers.

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)];

// create the button object
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor blackColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont boldSystemFontOfSize:20];
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 44.0);

// If you want to align the header text as centered
// headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0);

headerLabel.text = @" Section Title";
[customView addSubview:headerLabel];

return customView;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜