Latest 0.0.2
Homepage https://github.com/rosberry/Tribulus
License MIT
Platforms ios 8.0
Authors

Tribulus

Build Status
Version
Carthage Compatible
Platform
Swift 3.0.x
Test Coverage
License

Tribulus provides very convenient way to compose attributed strings.
It is a framework based on usage custom Attributes class and nice chaining syntax.

Installation 🏁

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Tribulus into your Xcode project using Carthage, specify it in your Cartfile:

github "rosberry/Tribulus"

Run carthage update to build the framework and drag the built Tribulus.framework into your Xcode project.

CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over eighteen thousand libraries and can help you scale your projects elegantly. You can install it with the following command:

$ sudo gem install cocoapods

To integrate Tribulus via CocoaPods, just add the following line to your Podfile:

pod "Tribulus"

Then, run the following command:

$ pod install

Manually

Drag Sources folder from latest release into your project.

Usage 🏄‍

Initialization

To initialize attributed string with required attributes, you can use following code:

let attributedString = NSAttributedString(string: testString) {
        $0.font = .systemFont(ofSize: 10, weight: UIFontWeightBold)
            $0.backgroundColor = .green
            $0.color = .black
            $0.baselineOffset = 14.0
            }

Appending

Tribulus also allows appending to existing mutable attributed string.

Here’s a code for appending new attributed string:

let attributedString = NSMutableAttributedString(string: "Foo")
attributedString
        .append(string: " Bar") {
            $0.color = .red
        }
        .append(string: " Baz") {
            $0.direction = .horizontal
        }

And in the same simple way you can append any image:

let attributedString = NSMutableAttributedString(string: "Foo")
attributedString.append(image: UIImage(named: "Bar"), 
                bounds: CGRect(x: 0, y: 0, width: 40, height: 40))

Insertion

Moreover Tribulus allows you to insert newly configured attributed string at any location:

let attributedString = NSMutableAttributedString(string: "Foo  Baz")
 attributedString
    .insert(string: "Bar", at: 4) {
            $0.textEffect = .letterpress
        }

or to insert an image:

attributedString.insert(image: UIImage(named: "Bar"), 
            bounds: CGRect(x: 0, y: 0, width: 40, height: 40), 
                        at: 0)

Additions

Instead on creating UIFontDescriptorSymbolicTraits you can just set bold and italic traits using Attributes object properties:

let attributedString = NSAttributedString(string: testString) {
        $0.bold = true
            $0.italic = true
        }

Author 🖌

Dmitry Frishbuter, [email protected]

About

Tribulus

This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.

Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.

License 📃

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

Latest podspec

{
    "name": "Tribulus",
    "version": "0.0.2",
    "summary": "Convenient attributed strings adjustment in Swift.",
    "description": "Tribulus provides very convenient way to compose attributed strings.nIt is a framework based on usage custom Attributes class and nice chaining syntax.",
    "homepage": "https://github.com/rosberry/Tribulus",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Dmitry Frishbuter": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rosberry/Tribulus.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Sources/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This