Attributed string in tableviewcell not showing bold text until the cell is dequeued and reloaded

家住魔仙堡 提交于 2019-12-01 17:24:47

I have same problem due to UIAppearance. Set font\color to nil before setting UILabel attributed text works for me.

I had a similar problem. I was trying to set attributed text (specifically font color) on a UILabel in my custom UITableViewCell and it was only partially reflecting the change, even if I did it in tableView:willDisplayCell:forRowAtIndexPath: (which I believe is the recommended place to do such updates).

It turned out that I needed to set the property on the main thread:

dispatch_async(dispatch_get_main_queue(), ^{
            [label setAttributedText:text];
        });

While I was already aware that all UI updates are to be done on the main thread, I was frankly surprised that willDisplayCell wasn't already called from the main thread, at least not in this case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!