StringStylizer alternatives and similar libraries
Based on the "Text" category.
Alternatively, view StringStylizer alternatives based on common mentions on social networks and blogs.
-
YYText
Powerful text framework for iOS to display and edit rich text. -
Nimbus
The iOS framework that grows only as fast as its documentation -
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. -
SwiftRichString
👩🎨 Elegant Attributed String composition in Swift sauce -
libPhoneNumber-iOS
iOS port from libphonenumber (Google's phone number handling library) -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
Down
Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark. -
TextAttributes
An easier way to compose attributed strings -
SwiftyMarkdown
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options. -
FontAwesome.swift
Use FontAwesome in your Swift projects -
SwiftString
A comprehensive, lightweight string extension for Swift -
Iconic
:art: Auto-generated icon font library for iOS, watchOS and tvOS -
MMMarkdown
An Objective-C framework for converting Markdown to HTML. -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
CocoaMarkdown
Markdown parsing and rendering for iOS and OS X -
SwiftIconFont
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon) -
FontBlaster
Programmatically load custom fonts into your iOS, macOS and tvOS app. -
Notepad
[iOS] A fully themeable markdown editor with live syntax highlighting. -
fuse-swift
A lightweight fuzzy-search library, with zero dependencies -
MarkdownKit
A simple and customizable Markdown Parser for Swift -
FormatterKit
stringWithFormat: for the sophisticated hacker set -
NSStringEmojize
A category on NSString to convert Emoji Cheat Sheet codes to their equivalent Unicode characters -
MarkdownTextView
Rich Markdown editing control for iOS -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
Guitar
A Cross-Platform String and Regular Expression Library written in Swift. -
Translucid
Lightweight library to set an Image as text background. Written in swift. -
Heimdall
Heimdall is a wrapper around the Security framework for simple encryption/decryption operations. -
GoogleMaterialDesignIcons
Google Material Design Icons Font for iOS -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html)
Appwrite - The open-source backend cloud platform
* 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 StringStylizer or a related project?
README
StringStylizer
Type strict builder class for NSAttributedString.
What's this?
StringStylizer makes NSAttributedString more intuitive with Method chain and Operator. Building NSAttributedString is so difficult because it requires us to remember attribute names and types. If you do that with StringStylizer, There is no need to remember them :smiley:
NSAttributedString has the following format.
let attr: [NSAttributedString.Key: Any] = [
.foregroundColor: UIColor.white,
.font: UIFont(name: "HelveticaNeue", size: 14)
]
let str = NSAttributedString(string: "some text", attributes: attr)
StringStylizer enable developers to read and write their code in a linear manner. If you wanna convert String to NSAttributedString which has some colors, sizes and fonts, you can write that as follows.
let str = "some text".stylize().color(.white).size(14).font(.HelveticaNeue).attr
Feature
- [x] Type strict format
- [x] Assigning ranges and attributes in a linear manner
- [x] More readable than NSAttributedString
Requirements
- iOS 8.0+
- Swift 5.0~ or Swift 4.0~ or Swift 3.2~
Installation
Carthage
- Install Carthage from Homebrew
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" > brew update > brew install carthage
- Move your project dir and create Cartfile
> touch Cartfile
- add the following line to Cartfile
github "kazuhiro4949/StringStylizer"
Create framework
> carthage update --platform iOS
In Xcode, move to "Genera > Build Phase > Linked Frameworks and Library"
Add the framework to your project
Add a new run script and put the following code
/usr/local/bin/carthage copy-frameworks
Click "+" at Input file and Add the framework path
$(SRCROOT)/Carthage/Build/iOS/StringStylizer.framework
Write Import statement on your source file
import StringStylizer
CocoaPods
- Install CocoaPods
> gem install cocoapods > pod setup
- Create Podfile
> pod init
- Edit Podfile ```ruby # Uncomment this line to define a global platform for your project platform :ios, '8.0' # add use_framework! # add
target 'MyAppName' do pod 'StringStylizer' # add end
target 'MyAppTests' do
end
target 'MyAppUITests'
+ Install
pod install
open .xcworkspace
Example
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
// build NSAttributedString.
let greeting = "Hi, ".stylize().color(0x2200ee).size(12).font(.HelveticaNeue).attr
// build NSAttributedString with ranges.
let msg = "something happened ".stylize()
.range(0..<9) .color(0x009911).size(12).font(.HelveticaNeue)
.range(10..<UInt.max).color(0xaa22cc).size(14).font(.HelveticaNeue_Bold).attr
// build NSAttributedString objects and join them.
let name = "to ".stylize().color(0x23abfc).size(12).font(.HelveticaNeue).attr +
"you".stylize().color(0x123456).size(14).font(.HelveticaNeue_Italic).underline(.double).attr
// build NSAttributedString objects with strikethrough and kerning applied.
let response = "\nHow ".stylize().attr + "boring".stylize().strikeThrough(.single).attr +
" exciting!".stylize().kern(-2).attr
This sample generates a styled label.
Of course, you can wrap up the method chains.
extension StringStylizer {
func strong() -> NSAttributedString {
return self
.color(0x123456)
.size(14)
.font(.HelveticaNeue_Italic)
.underline(.double)
.attr
}
}
label.attributedText = "you".stylize().strong()
Usage
1. Convert String to StringStylizer object
let firstStep = "yay!".stylize() // => StringStylizer<Styling>
1a. Alternatively, use an optional String
let optionalString:String? = nil
let firstStep = optionalString.stylize() // => StringStylizer<Styling>
2. Call methods to select range. Then, StringStylizer change into "NarrowDown" state
let secondStep = "yay!".stylize().range(0..<UInt.max) // => StringStylizer<NarrowDown>
3. Call methods to set attributes. Then, StringStylizer change into "Styling" state
let thirdStep = "yay!".stylize().range(0..<UInt.max).size(14) // => StringStylizer<Styling>
4. Convert to NSAttributedString object.
let fourthStep = "yay!".stylize().range(0..<UInt.max).size(14).attr // => NSAttributedString
5. Join another NSAttributedString object.
let one = "yay!".stylize().range(0..<UInt.max).size(14).attr
let another = " yay!".stylize().color(0xffffff).attr
let fifthStep = one + another // => NSAttributedString
That's it!
Architecture
StringStylizer is based on "Builder Pattern" (Effective Java version). In addition, it has states managed by "Phantom Type".
Because of them, we are able to
- write our code in a linear manner
- call proper methods depending on the situation.
License
Copyright (c) 2016 Kazuhiro Hayashi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*Note that all licence references and agreements mentioned in the StringStylizer README section above
are relevant to that project's source code only.