CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

Tribulus 0.0.2

Tribulus 0.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Dmitry Frishbuter.



Tribulus 0.0.2

  • By
  • Dmitry Frishbuter

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

Installation 🏁

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]

License 📃

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