AliSoftware / OHAttributedLabel

UILabel that supports NSAttributedString
https://github.com/AliSoftware/OHAttributedLabel/wiki
1.51k stars 344 forks source link

Links are not colorised when using setLink:range: #128

Closed Frizlab closed 11 years ago

Frizlab commented 11 years ago

Hello,

I tried migrated to the new way of adding links, that is directly to the attributed string instead of telling the label to add the links. The links were indeed detected (I was able to tap on them), but they were not colorised.

I did a bit a searching and I think I found the root cause of the problem. As I understand, the colorisation is done in recomputeLinksInTextIfNeeded. In this method there is a test to check whether it is actually needed to recompute links or not. The test goes as follow: if (!_attributedText || (self.automaticallyAddLinksForType == 0 && _customLinks.count == 0)). When using setLink:range:, none of the tests becomes false, then the link computation is given up which result in links not being colorised.

Thanks for your wonderful library by the way, it saved my life :) Sorry if I missed anything.

AliSoftware commented 11 years ago

You're right, there's an issue here. Will try to fix that anytime soon!

Frizlab commented 11 years ago

Any news?

AliSoftware commented 11 years ago

Fixed by merge of #135 (see commit 362f9fa4848b4ed22d0a0b7c11702ebf9721d8b0)