Is there a way to create custom UIDataDetectorTypes?

前端 未结 5 1753
忘了有多久
忘了有多久 2020-12-20 07:03

What I am trying to do is create tooltip functionality so that certain words in my instructional app can be tapped and the definition pops up. For the popup part I plan on

5条回答
  •  渐次进展
    2020-12-20 07:19

    If you want custom data detector you could write an extractor method to primarly patch the links with help of NSregularExpression. For example

    NSString regex = @"(http|https|fb)://((\w)|([0-9]*)|([-|_]))+(\.|/)"; to patch alll the links including Facebook URLs inside text like fb://friends.

    Then you could use NSattributedString yo mark the links with different colors etc.

    ThreeTwenty has a great library called TTTAttributedLabel where you could assign links to certain parts of a text. I also scrolls quite fast if you use it in tableviews

    https://github.com/mattt/TTTAttributedLabel

提交回复
热议问题