Điểm qua optonaut/ActiveLabel.swift: 4.6k sao trên GitHub, viết chủ yếu bằng Swift, thuộc nhóm Mobile. UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
UILabel drop-in replacement supporting Hashtags (#), Mentions (@), URLs (http://), Emails and custom regex patterns, written in Swift
Features
Swift 5.0 (1.1.0+) and 4.2 (1.0.1)
Default support for Hashtags, Mentions, Links, Emails
Support for custom types via regex
Ability to enable highlighting only for the desired types
Ability to trim urls
Super easy to use and lightweight
Works as UILabel drop-in replacement
Well tested and documented
Install (iOS 10+)
Carthage
Add the following to your Cartfile and follow these instructions
github "optonaut/ActiveLabel.swift"
CocoaPods
CocoaPods 0.36 adds supports for Swift and embedded frameworks. To integrate ActiveLabel into your project add the following to your Podfile:
platform :ios, '10.0'
use_frameworks!
pod 'ActiveLabel'
Usage
import ActiveLabel
let label = ActiveLabel()
label.numberOfLines = 0
label.enabledTypes = [.mention, .hashtag, .url, .email]
label.text = "This is a post with #hashtags and a @userhandle."
label.textColor = .black
label.handleHashtagTap { hashtag in
print("Success. You just tapped the \(hashtag) hashtag")
}
Custom types
let customType = ActiveType.custom(pattern: "\\swith\\b") //Regex that looks for "with"
label.enabledTypes = [.mention, .hashtag, .url, .email, customType]
label.text = "This is a post with #hashtags and a @userhandle."
label.customColor[customType] = UIColor.purple
label.customSelectedColor[customType] = UIColor.green
label.handleCustomTap(for: customType) { element in
print("Custom type tapped: \(element)")
}
Enable/disable highlighting
By default, an ActiveLabel instance has the following configuration
But feel free to enable/disable to fit your requirements
Batched customization
When 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.
When using customize(block:), you can group all the customizations on the label, that way ActiveLabel is only going to refresh the textContainer once.
label.handleCustomTap(for: customType) { element in print("\(element) tapped") }
filterHashtag: (String) -> Bool
label.filterHashtag { hashtag in validHashtags.contains(hashtag) }
filterMention: (String) -> Bool
label.filterMention { mention in validMentions.contains(mention) }
Alternatives
Before 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.
TTTAttributedLabel (ObjC) - A drop-in replacement for UILabel that supports attributes, data detectors, links, and more
STTweetLabel (ObjC) - A UILabel with #hashtag @handle and links tappable
AMAttributedHighlightLabel (ObjC) - A UILabel subclass with mention/hashtag/link highlighting
KILabel (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
optonaut/ActiveLabel.swift thuộc nhóm Mobile trên TopGit, cùng 4 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về optonaut/ActiveLabel.swift ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/optonaut/ActiveLabel.swift là nguồn chính thức.
optonaut/ActiveLabel.swift có phải mã nguồn mở không?
Có — optonaut/ActiveLabel.swift phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/optonaut/ActiveLabel.swift.
optonaut/ActiveLabel.swift có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho optonaut/ActiveLabel.swift. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
optonaut/ActiveLabel.swift dùng license gì?
optonaut/ActiveLabel.swift phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
optonaut/ActiveLabel.swift là gì?
optonaut/ActiveLabel.swift (optonaut/ActiveLabel.swift) là dự án Swift trên GitHub. Theo mô tả gốc: UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
Vì sao optonaut/ActiveLabel.swift được xếp vào nhóm Mobile?
TopGit xếp optonaut/ActiveLabel.swift vào nhóm Mobile dựa trên GitHub topics và mô tả của repo (gắn thẻ: "activelabel", "swift", "twitter"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về ActiveLabel.swift?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về ActiveLabel.swift.