Latest 0.9.6
Homepage https://github.com/tottakai/Thongs
License MIT
Platforms ios 8.0
Authors

Thongs is a library for making NSAttributedString creation humane in Swift 4.

CI Status
Version
License
Platform

Usage

import Thongs

// Create a formatter by combining different attributes, such as font, color, kerning...
// then style the string with the formatter
let red = Thongs.color(UIColor(red: 231/255, green: 76/255, blue: 60/255, alpha: 1))
let large = Thongs.font(UIFont(name: "Avenir-Black", size: 28)!)
let kerning = Thongs.kerning(1.4)
let titleFormatter = red <*> large <*> kerning
titleLabel.attributedText = titleFormatter(Thongs.string("This thing right here"))

// combine string attributes with the <*> operator
// combine differently styled parts using the <+> operator
let bodyTextFontStyle1 = Thongs.font(UIFont(name: "Baskerville-SemiBoldItalic", size: 24)!)
let bodyTextFontStyle2 = Thongs.font(UIFont(name: "BradleyHandITCTT-Bold", size: 16)!)
let formatter1 = bodyTextFontStyle1 <*> Thongs.color(UIColor(red: 46/255, green: 204/255, blue: 113/255, alpha: 1))
let formatter2 = bodyTextFontStyle2 <*> Thongs.color(UIColor(red: 34/255, green: 167/255, blue: 240/255, alpha: 1))
let formatter3 = bodyTextFontStyle1 <*> Thongs.color(UIColor(red: 232/255, green: 126/255, blue: 4/255, alpha: 1))
let formatter4 = bodyTextFontStyle2 <*> Thongs.color(UIColor(red: 191/255, green: 85/255, blue: 236/255, alpha: 1))
let formatter5 = bodyTextFontStyle1 <*> Thongs.color(UIColor(red: 245/255, green: 215/255, blue: 110/255, alpha: 1))
let formattedLine = Thongs.font(UIFont(name: "Courier", size: 16)!) <*> Thongs.color(UIColor(red: 103/255, green: 65/255, blue: 114/255, alpha: 1)) ~~> "Check it outn"

textBox.attributedText = formatter1 ~~> "Is lettin all the ladies known" <+>
        formatter2 ~~> "What guys talk aboutn" <+>
        formatter3 ~~> "You known" <+>
        formatter4 ~~> "The finer things in lifen" <+>
        formatter5 ~~> "Hahahan" <+>
        formattedLine

Supports color, font, kerning, underline and strikethrough, but is easily extendable. Pull requests are welcome.

Installation

Thongs is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Thongs"

Author

Tomi Koskinen, [email protected]

License

Thongs is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Thongs",
    "version": "0.9.6",
    "summary": "Functional library for NSAttributedString creation in swift 4.",
    "description": "A functional NSAttributedString builder, allows composition of a complex NSAttributedString from multiple parts with different style attributes.",
    "homepage": "https://github.com/tottakai/Thongs",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Tomi Koskinen": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tottakai/Thongs.git",
        "tag": "0.9.6"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Thongs/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This