Latest 0.0.1
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit


CREasyStyleTextStorage is a NSTextStorage subclass that provides a convenient way to apply distinct styles to substrings. There is a demo project showing a general use case for it. PR’s and Issues welcome. Lots more functionality to come.

Basic Usage

CREasyStyleTextStorage allows for specific strings to have unique styling. Configuring and using in a UITextView would look something like this.

CREasyStyleTextStorage *textStorage = [[CREasyStyleTextStorage alloc] init];

// Set default attributes

[textStorage setDefaultAttributes:@{NSFontAttributeName             : [UIFont systemFontOfSize:14],
                                    NSForegroundColorAttributeName  : [UIColor blackColor]}];

// Make '@' symbols red

[textStorage setAttributes:@{NSForegroundColorAttributeName : [UIColor redColor]} 

// Make '#' symbols green

[textStorage setAttributes:@{NSForegroundColorAttributeName : [UIColor greenColor]} 

NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
NSTextContainer *container = [[NSTextContainer alloc] initWithSize:self.view.bounds.size];
[layoutManager addTextContainer:container];

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectZero textContainer:container];
[self.view addSubview:textView];

Latest podspec

    "name": "CREasyStyleTextStorage",
    "version": "0.0.1",
    "license": "MIT",
    "summary": "NSTextStore subclass for easy text styling",
    "description": "CREasyStyleTextStorage is a concrete NSTextStore subclass that allows for fast exact string match styling.",
    "homepage": "",
    "authors": "Collin Ruffenach",
    "source": {
        "git": "",
        "tag": "0.0.1"
    "platforms": {
        "ios": "7.0"
    "source_files": "CREasyStyleTextStorage",
    "frameworks": "UIKit",
    "requires_arc": true

Pin It on Pinterest

Share This