Shortcut in lock background UITableViewCell

I have a problem with a shortcut inside my UITableViewCellblocking background image. It seems that this happens only in an unselected state. I tried to set the background colors to clear, but that didn't do it. It takes the background color of the table. Should I also set the background image of the tags?

// Neither of these worked...
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];

screen shot

Here is my cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SimpleTableIdentifier"] autorelease];
    }

    UIImage *image = [UIImage imageNamed:@"TableRow.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.contentMode = UIViewContentModeScaleToFill;
    cell.backgroundView = imageView;
    [imageView release];

    UIImage *imageSelected = [UIImage imageNamed:@"TableRowSelected.png"];
    UIImageView *imageViewSelected = [[UIImageView alloc] initWithImage:imageSelected];
    imageViewSelected.contentMode = UIViewContentModeScaleToFill;
    cell.selectedBackgroundView = imageViewSelected;
    [imageViewSelected release];


    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.text = [[self.trivia.questionsets objectAtIndex:indexPath.row] valueForKeyPath:@"title"];

    return cell;
}

UPDATE : Allowed ...

If I set the background color of the table (which I assumed would be under everything) to clear, then suddenly my image shows where I expect, but the background of the table is now displayed on top of everything? Is this expected behavior? (We have not checked the documents yet)

tableView.backgroundColor = [UIColor redColor];
cell.contentView.backgroundColor = [UIColor orangeColor];
cell.textLabel.backgroundColor = [UIColor yellowColor];

screen shot 2

... and finish, if I set both the background color of the table and the cell, we are good. The background color of textlabel does not matter.

tableView.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.textLabel.backgroundColor = [UIColor yellowColor];

screen shot 3

+3
1

, .

- , . - (.. ), .

0

Source: https://habr.com/ru/post/1724951/


All Articles