[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6867":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},6867,"ActiveLabel.swift","optonaut\u002FActiveLabel.swift","optonaut","UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http:\u002F\u002F) written in Swift","",null,"Swift",4609,680,51,24,0,4,60.9,"MIT License",false,"master",true,[24,25,26,27],"activelabel","swift","twitter","uilabel","2026-06-12 04:00:30","# ActiveLabel.swift [![Carthage compatible](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCarthage-compatible-4BC51D.svg?style=flat)](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage) [![Build Status](https:\u002F\u002Ftravis-ci.org\u002Foptonaut\u002FActiveLabel.swift.svg)](https:\u002F\u002Ftravis-ci.org\u002Foptonaut\u002FActiveLabel.swift)\n\nUILabel drop-in replacement supporting Hashtags (#), Mentions (@), URLs (http:\u002F\u002F), Emails and custom regex patterns, written in Swift\n\n## Features\n\n* Swift 5.0 (1.1.0+) and 4.2 (1.0.1)\n* Default support for **Hashtags, Mentions, Links, Emails**\n* Support for **custom types** via regex\n* Ability to enable highlighting only for the desired types\n* Ability to trim urls\n* Super easy to use and lightweight\n* Works as `UILabel` drop-in replacement\n* Well tested and documented\n\n![](ActiveLabelDemo\u002Fdemo.gif)\n\n## Install (iOS 10+)\n\n### Carthage\n\nAdd the following to your `Cartfile` and follow [these instructions](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage#adding-frameworks-to-an-application)\n\n```sh\ngithub \"optonaut\u002FActiveLabel.swift\"\n```\n\n### CocoaPods\n\nCocoaPods 0.36 adds supports for Swift and embedded frameworks. To integrate ActiveLabel into your project add the following to your `Podfile`:\n\n```ruby\nplatform :ios, '10.0'\nuse_frameworks!\n\npod 'ActiveLabel'\n```\n\n## Usage\n\n```swift\nimport ActiveLabel\n\nlet label = ActiveLabel()\nlabel.numberOfLines = 0\nlabel.enabledTypes = [.mention, .hashtag, .url, .email]\nlabel.text = \"This is a post with #hashtags and a @userhandle.\"\nlabel.textColor = .black\nlabel.handleHashtagTap { hashtag in\n    print(\"Success. You just tapped the \\(hashtag) hashtag\")\n}\n```\n\n## Custom types\n\n```swift\nlet customType = ActiveType.custom(pattern: \"\\\\swith\\\\b\") \u002F\u002FRegex that looks for \"with\"\nlabel.enabledTypes = [.mention, .hashtag, .url, .email, customType]\nlabel.text = \"This is a post with #hashtags and a @userhandle.\"\nlabel.customColor[customType] = UIColor.purple\nlabel.customSelectedColor[customType] = UIColor.green\nlabel.handleCustomTap(for: customType) { element in\n    print(\"Custom type tapped: \\(element)\")\n}\n```\n\n## Enable\u002Fdisable highlighting\n\nBy default, an ActiveLabel instance has the following configuration\n\n```swift\nlabel.enabledTypes = [.mention, .hashtag, .url, .email]\n```\n\nBut feel free to enable\u002Fdisable to fit your requirements\n\n## Batched customization\n\nWhen using ActiveLabel, it is recommended to use the `customize(block:)` method to customize it. The reason is that ActiveLabel is reacting to each property that you set. So if you set 3 properties, the textContainer is refreshed 3 times.\n\nWhen using `customize(block:)`, you can group all the customizations on the label, that way ActiveLabel is only going to refresh the textContainer once.\n\nExample:\n\n```swift\nlabel.customize { label in\n    label.text = \"This is a post with #multiple #hashtags and a @userhandle.\"\n    label.textColor = UIColor(red: 102.0\u002F255, green: 117.0\u002F255, blue: 127.0\u002F255, alpha: 1)\n    label.hashtagColor = UIColor(red: 85.0\u002F255, green: 172.0\u002F255, blue: 238.0\u002F255, alpha: 1)\n    label.mentionColor = UIColor(red: 238.0\u002F255, green: 85.0\u002F255, blue: 96.0\u002F255, alpha: 1)\n    label.URLColor = UIColor(red: 85.0\u002F255, green: 238.0\u002F255, blue: 151.0\u002F255, alpha: 1)\n    label.handleMentionTap { self.alert(\"Mention\", message: $0) }\n    label.handleHashtagTap { self.alert(\"Hashtag\", message: $0) }\n    label.handleURLTap { self.alert(\"URL\", message: $0.absoluteString) }\n}\n```\n\n## Trim long urls\n\nYou have the possiblity to set the maximum lenght a url can have;\n\n```swift\nlabel.urlMaximumLength = 30\n```\n\nFrom now on, a url that's bigger than that, will be trimmed.\n\n`https:\u002F\u002Fafancyurl.com\u002Fwhatever` -> `https:\u002F\u002Fafancyurl.com\u002Fwh...`\n\n## API\n\n##### `mentionColor: UIColor = .blueColor()`\n##### `mentionSelectedColor: UIColor?`\n##### `hashtagColor: UIColor = .blueColor()`\n##### `hashtagSelectedColor: UIColor?`\n##### `URLColor: UIColor = .blueColor()`\n##### `URLSelectedColor: UIColor?`\n##### `customColor: [ActiveType : UIColor]`\n##### `customSelectedColor: [ActiveType : UIColor]`\n##### `lineSpacing: Float?`\n\n##### `handleMentionTap: (String) -> ()`\n\n```swift\nlabel.handleMentionTap { userHandle in print(\"\\(userHandle) tapped\") }\n```\n\n##### `handleHashtagTap: (String) -> ()`\n\n```swift\nlabel.handleHashtagTap { hashtag in print(\"\\(hashtag) tapped\") }\n```\n\n##### `handleURLTap: (NSURL) -> ()`\n\n```swift\nlabel.handleURLTap { url in UIApplication.shared.openURL(url) }\n```\n\n##### `handleEmailTap: (String) -> ()`\n\n```swift\nlabel.handleEmailTap { email in print(\"\\(email) tapped\") }\n```\n\n##### `handleCustomTap(for type: ActiveType, handler: (String) -> ())`\n\n```swift\nlabel.handleCustomTap(for: customType) { element in print(\"\\(element) tapped\") }\n```\n\n##### `filterHashtag: (String) -> Bool`\n\n```swift\nlabel.filterHashtag { hashtag in validHashtags.contains(hashtag) }\n```\n\n##### `filterMention: (String) -> Bool`\n\n```swift\nlabel.filterMention { mention in validMentions.contains(mention) }\n```\n\n## Alternatives\n\nBefore writing `ActiveLabel` we've tried a lot of the following alternatives but weren't quite satisfied with the quality level or ease of usage, so we decided to contribute our own solution.\n\n* [TTTAttributedLabel](https:\u002F\u002Fgithub.com\u002FTTTAttributedLabel\u002FTTTAttributedLabel) (ObjC) - A drop-in replacement for UILabel that supports attributes, data detectors, links, and more\n* [STTweetLabel](https:\u002F\u002Fgithub.com\u002FSebastienThiebaud\u002FSTTweetLabel) (ObjC) - A UILabel with #hashtag @handle and links tappable\n* [AMAttributedHighlightLabel](https:\u002F\u002Fgithub.com\u002Frootd\u002FAMAttributedHighlightLabel) (ObjC) - A UILabel subclass with mention\u002Fhashtag\u002Flink highlighting\n* [KILabel](https:\u002F\u002Fgithub.com\u002FKrelborn\u002FKILabel) (ObjC) - A simple to use drop in replacement for UILabel for iOS 7 and above that highlights links such as URLs, twitter style usernames and hashtags and makes them touchable\n","ActiveLabel.swift是一个用Swift编写的UILabel替代品，支持识别和高亮显示Hashtags、Mentions、URLs和电子邮件。其核心功能包括对默认类型（如标签、提及、链接、邮件）的支持以及通过正则表达式定义自定义类型的灵活性，同时提供针对特定类型启用高亮的功能。此外，它还允许用户修剪URL，并且非常易于集成与使用，作为UILabel的直接替换组件而无需大量代码修改。适用于需要在iOS应用中实现文本内互动元素（比如社交媒体客户端或即时通讯软件）的场景。",2,"2026-06-11 03:09:17","top_language"]