Giter Club home page Giter Club logo

tribulus's Introduction

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

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.

tribulus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.