开发者

UItableviewcell textlabel background color issue

开发者 https://www.devze.com 2023-02-18 14:32 出处:网络
cell.textLabel.backgroundColor = [UIColor clearColor]; does not work in iPad3.2.2 but it works fine in 4.2.
cell.textLabel.backgroundColor = [UIColor clearColor];

does not work in iPad3.2.2 but it works fine in 4.2.

can anyone help in clea开发者_StackOverflowr the cell text background color.

what my requirement is I need to show the cell.backgroundView clearly.

thanks in advance


By default UIKit will set the backgroundColor's of all subviews when selecting it.

If you want something differently subclass UITableViewCell and add this method to your subclass:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    [[self textLabel] setBackgroundColor:[UIColor clearColor]];
    [[self detailTextLabel] setBackgroundColor:[UIColor clearColor]];
}


-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

  [[cell textLabel]setBackground:[UIColor clearColor]];

}

Try this brother I hope work fine in very iOS version.


I have the same issue in an iPad running 4.3.3.

[cell.textLabel setBackgroundColor:[UIColor grayColor]];

this works to me.

Background color is a real nightmare ! good luck

0

精彩评论

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