Прозрачный фон UITableViewCell (включая imageView/accessoryView)

Я использовал Sqliteman в прошлом. Довольно хороший.

10
задан Community 8 February 2017 в 14:15
поделиться

2 ответа

Бен и я выяснили это сегодня, вот сводка для группы на случай, если это кого-нибудь зацепит.

Вы должны установить фон ячейки и cell.textLabel.backgroundColor каждый раз, когда вызывается cellForRowAtIndexPath , а не только во время фазы alloc / init (т.е. если tableView имеет промах в кэше удаления из очереди).

Итак, код становится следующим:

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        cell.opaque = NO;        
    }

    // All bgColor configuration moves here
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.backgroundColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:.4];
    cell.textColor = [UIColor whiteColor];
    cell.imageView.image = [icons objectAtIndex:indexPath.row];
    cell.textLabel.text = [items objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}
16
ответ дан 3 December 2019 в 20:42
поделиться

Ну, вы не определили, что вы пытаетесь сделать, но если вам нужен интерфейс C ++,

2
ответ дан 3 December 2019 в 20:42
поделиться
Другие вопросы по тегам:

Похожие вопросы: