Tribute alternatives and similar libraries
Based on the "Text" category.
Alternatively, view Tribute alternatives based on common mentions on social networks and blogs.
-
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
ZSSRichTextEditor
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view -
Twitter Text Obj
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform. -
FontAwesomeKit
Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons. -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
DISCONTINUED. RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
SwiftyMarkdown
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options. -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
SwiftIconFont
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon) -
NSStringEmojize
A category on NSString to convert Emoji Cheat Sheet codes to their equivalent Unicode characters -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
Heimdall
Heimdall is a wrapper around the Security framework for simple encryption/decryption operations. -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html)
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Tribute or a related project?
README
Tribute
let string = NSMutableAttributedString().add("Hello ") {
$0.font = .systemFontOfSize(20)
$0.color = .redColor()
$0.underline = .StyleSingle
}.add("world ") {
$0.stroke = .Filled(width: 2)
$0.strokeColor = .orangeColor()
}.add("of Swift "){
$0.font = .systemFontOfSize(12)
$0.underline = nil
$0.URL = NSURL(string: "http://swift.org")!
}.add(UIImage(named: "swift")!)
Not bad comparing to
let string2 = NSMutableAttributedString()
string2.appendAttributedString(NSAttributedString(string: "Hello ", attributes: [
NSFontAttributeName: UIFont.systemFontOfSize(20),
NSUnderlineStyleAttributeName: NSUnderlineStyle.StyleSingle.rawValue,
NSForegroundColorAttributeName: UIColor.redColor()
]))
string2.appendAttributedString(NSAttributedString(string: "world ", attributes: [
NSFontAttributeName: UIFont.systemFontOfSize(20),
NSUnderlineStyleAttributeName: NSUnderlineStyle.StyleSingle.rawValue,
NSForegroundColorAttributeName: UIColor.redColor(),
NSStrokeColorAttributeName: UIColor.orangeColor(),
NSStrokeWidthAttributeName: -2
]))
string2.appendAttributedString(NSAttributedString(string: "of Swift ", attributes: [
NSFontAttributeName: UIFont.systemFontOfSize(12),
NSForegroundColorAttributeName: UIColor.redColor(),
NSStrokeColorAttributeName: UIColor.orangeColor(),
NSStrokeWidthAttributeName: -2
]))
let attachment = NSTextAttachment()
attachment.image = UIImage(named: "swift")
string2.appendAttributedString(NSAttributedString(attachment: attachment))
Design Goals
- Word processor logic: appending a string should inherit last attributes.
- Allow for easy customization of common properties, including toggle bold or change the font size.
- Flatten paragraph style and attributes, no more 5 lines of code if all you wanted is to change text alignment.
- Replace weird attributes with more reasonable versions (for example
Attribute.Stroke
vs NSStrokeWidthAttributeName). - Minimal overhead: produce only required attributes.
- Have an attributed string ready to use every time you leave the configuration block.
- Replace string constants with strongly typed enums where possible.
Notes
Playground
Playgrounds do not always render NSAttributesString
correctly (font variations and attachments are few of the problematic I noticed).
Workaround: Use a UILabel
as a live view instead: XCPlaygroundPage.currentPage.liveView = label
.
Font variations
Not all fonts have both italic and bold variations
Workaround: Use obliqueness
property as a poor man italic, and expansion
as a bold respectively.
Closure with one statement
When the configuration closure includes only one statement, compiler gets confused
Workaround: Specify closure type explicitly like so
string.add("text") { (inout a: Attributes) in
a.color = .redColor()
}
If you know a better way, please open a PR, I'd love to learn from it!
Roadmap
- [ ] Objective-C compatibility
- [ ] Moar attributes (PRs are welcome)
This is just a tribute