UITableViewCell textColor will not change with userInteractionEnabled = NO

前端 未结 2 1866
粉色の甜心
粉色の甜心 2020-12-21 03:45

I am trying to simply change the color of my UILabel using the textColor property and it will not work when userInteraction is disabled, this does

相关标签:
2条回答
  • 2020-12-21 04:17

    Ok I know how to fix this but it does NOT make any sense at all, the problem is this line:

    cell.userInteractionEnabled = NO;
    

    If removed the textColor changes, the odd thing is that if i change the user interaction at the end after changing the textColor the color changes!

    Is this a bug?. I hope this answer helps anyone trying to figure this out as it does not make any sense at all, and there is no documentation about this.

    0 讨论(0)
  • 2020-12-21 04:30

    Please check my answer to a similar question:

    https://stackoverflow.com/a/18552074/921573

    Setting the enabled property on the textLabels accordingly fixes this:

    cell.userInteractionEnabled = (indexPath.row % 2) == 0;
    cell.textLabel.enabled = cell.isUserInteractionEnabled;
    cell.detailTextLabel.enabled = cell.isUserInteractionEnabled;
    
    0 讨论(0)
提交回复
热议问题