Latest 0.1
Homepage https://github.com/jPaolantonio/JPAttributedStringBuilder
License MIT
Platforms ios 7.0, requires ARC

A DSL for creating NSStrings and NSAttributedStrings

Build Status
Version
Platform

Installation

Install with CocoaPods:

pod 'JPAttributedStringBuilder'

Usage

NSAttributedString Creation

Have you ever had to append a bunch of NSAttributedStrings?

NSMutableAttributedString *text = [[NSMutableAttributedString alloc] init];

 initWithString:firstName
                                     attributes:@{
                                                  NSFontAttributeName : [UIFont boldSystemFont:12.0f],
                                                  NSForegroundColorAttributeName : [UIColor blackColor]
                                                  }]];

 initWithString:[NSString stringWithFormat:@"%@n", self.search.neighborhoodsString]
                                     attributes:@{
                                                  NSFontAttributeName : [UIFont proximaNovaBoldWithSize:16.0f],
                                                  NSForegroundColorAttributeName : [UIColor ucDarkColor]
                                                  }]];

 initWithString:[NSString stringWithFormat:@"%@", self.bedPriceString]
                                     attributes:@{
                                                  NSFontAttributeName : [UIFont proximaNovaRegularWithSize:14.0f],
                                                  NSForegroundColorAttributeName : [UIColor ucDarkColor]
                                                  }]];

Is this better?

JPAttributedStringBuilder *stringBuilder = [[JPAttributedStringBuilder alloc] init];
stringBuilder.font = [UIFont systemFontOfSize:14.f];
stringBuilder.foregroundColor = [UIColor redColor];
stringBuilder.backgroundColor = [UIColor lightGrayColor];
stringBuilder.text = @"This is a better string";

NSAttributedString *jpAttributedString = [stringBuilder build];

Examples

There is an example included with the project. To install,

$ pod install
$ open ZipLocateSample.xcworkspace/

Contribute

Send me pull requests!

Authors

James Paolantonio – @jpaolantonio

Extra

Let me know if you are using this or want anything changed!! :)

Latest podspec

{
    "name": "JPAttributedStringBuilder",
    "version": "0.1",
    "summary": "An easier way to work with NSAttributedStrings",
    "description": "                   A builder for JPAttributedStrings. Makes working working with NSAttributedStrings much easier.n",
    "homepage": "https://github.com/jPaolantonio/JPAttributedStringBuilder",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "James Paolantonio",
    "social_media_url": "http://twitter.com/jPaolantonio",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/jPaolantonio/JPAttributedStringBuilder.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "JPAttributedStringBuilder",
        "JPAttributedStringBuilder/**/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This