Как изменить цвет текста UITableViewController (Сгруппированный)? - PullRequest
2 голосов
/ 22 июля 2011

Быстрый вопрос:

Как я могу изменить цвет текста метки раздела, который у меня есть, в UITableViewController, сгруппированный стиль? EDIT:

Пример

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{


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


    }
   }

Я хочу, чтобы "A", "B", "C" были белыми. Предложения?

1 Ответ

3 голосов
/ 22 июля 2011

Я не думаю, что вы можете изменить цвет заголовка / размер вашего раздела. Об этом упоминалось на яблочных форумах.

То, что вы можете сделать, - реализовать собственную метку / представление для заголовков разделов.

- (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;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...