简体   繁体   中英

How to detect and make hyperlinks/mentions/hashtags clickable in UILabel?

How to detect and make link/mention/hashtag clickable in UILabel. Alternatively, is there any open source library that I can utilize (I already looked at Fancy UILabel which doesn't handle multiline tex, TTAttributedLabel which doesn't handle mention/hashtag)?

There is no way to do so with UILabel in the current iOS...

TTTAttributedLabel will let you style up your label, however for clickable (or rather - tappable ) links you should rather either use a UIWebView and style it in such a was as to disguise it as a Label, or, you could get geeky and split your labels up and use a UIButton in the mix, but that's very messy - like a puzzle, only... they don't fit together.

Last option you might have is to overlay a UIButton over a link, but this requires that you know where the link is and since the question was about detecting links etc...

You should really look into UIWebView.

You can achieve this using following library:

https://github.com/SebastienThiebaud/STTweetLabel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM