Tak ... To teraz działa świetnie!
stworzyłem tableView:viewForHeaderInSection:
metody i stworzył UIView
UIView *customTitleView = [ [UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
Potem stworzyłem UILabel & ustawić tekst ceni & kolory na etykiecie. Potem dodaje etykietę do widoku
UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
titleLabel.text = @"<Title string here>";
titleLabel.textColor = [UIColor whiteColor];
titleLabel.backgroundColor = [UIColor clearColor];
[customTitleView addSubview:titleLabel];
Więc moja metoda tableView:viewForHeaderInSection:
wygląda jak ...
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *customTitleView = [ [UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
titleLabel.text = @"<Title string here>";
titleLabel.textColor = [UIColor whiteColor];
titleLabel.backgroundColor = [UIColor clearColor];
[customTitleView addSubview:titleLabel];
return customTitleView;
}
Dodajmy tableView:heightForHeaderInSection:
sposobu dostarczania trochę miejsca do tytułu.
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 44;
}
Jeśli to rozwiązało problemu, należy oznaczyć ją jako zaakceptowane. –
pięknie napisane .. dziękuję, przydatne nawet teraz ;-) – thandasoru
Właściwie nie musisz tego UIView. Wystarczy bezpośrednio zwrócić UILabel jako headerView jest w porządku też. – GeneCode