Latest0.1.1
Homepagehttps://github.com/SeekingAlpha/SALAttributedStringExtentions
LicenseMIT
Platformsios 7.0, requires ARC
Dependencieshpple, SDWebImage
FrameworksUIKit
Authors

Improves NSAttributedString functionalities, starting with the convertion from HTML to attributed string

  • Asynchrounsly download images.
  • Adds placeholder.
  • Auto Resize image to fit in line.

[![CI Status](http://img.shields.io/travis/Marcio Klepacz/SALAttributedStringExtentions.svg?style=flat)](https://travis-ci.org/Marcio Klepacz/SALAttributedStringExtentions)
Version
License
Platform

Performance

Converting using the default API

Without

Converting using SALAttributedStringExtentions

With the extentiosn

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Just need to create a new object and set the delegate:

SALAttributedStringExtensions *attributedStringExtended = [[SALAttributedStringExtensions alloc] init];
attributedStringExtended.delegate = self;    

NSAttributedString *attrString = [attributedStringExtended attributedStringFromHTML:HTML limitingImageHeight:300];

Implementing the delegates:

#pragma mark - SALAttributedStringDelegate
- (UIImage *)imagePlaceholder
{
    return [UIImage imageNamed:@"your-image-placeholder-name"];
}

- (void)textAttachmentDownloaded:(SALResizableTextAttachment *)textAttachment inRange:(NSRange)range
{
    // Just add the textAttachment on your textStorage
    [self.textView.textStorage addAttribute:NSAttachmentAttributeName value:textAttachment range:range];
}

Other options:

//Creating without passing a limit height
NSAttributedString *attrString = [attributedStringExtended attributedStringFromHTML:HTML];

//Creating with a custom textAttachment background color
NSAttributedString *attrString = [attributedStringExtended attributedStringFromHTML:HTML withTextAttachmentBackgroundColor:[UIColor blackColor]];

Requirements

  • iOS7 +

Installation

SALAttributedStringExtentions is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SALAttributedStringExtentions"

The horizon

  • [x] Download images asynchonously.
  • [x] Add to Cocoapod.
  • [x] Iframe support.
  • [ ] Tap to enlarge images.
  • [ ] Table support.
  • [ ] Youtube support.
  • [ ] 99% Unit test coverage
  • [ ] Remove third party framewroks dependency.
  • [ ] Recoginize data-image-width,height.

License

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

Latest podspec

{
    "name": "SALAttributedStringExtentions",
    "version": "0.1.1",
    "summary": "High performance/optimized conversion from HTML to NSAttributedString",
    "description": "                       Improves NSAttributedString functionalities, starting with the convertion from HTML to attributed stringn* Asynchrounsly download images.n* Adds placeholder.n* Auto Resize image to fit in line. n",
    "homepage": "https://github.com/SeekingAlpha/SALAttributedStringExtentions",
    "license": "MIT",
    "authors": {
        "Marcio Klepacz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/SeekingAlpha/SALAttributedStringExtentions.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/marciok",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes",
    "resource_bundles": {
        "SALAttributedStringExtentions": [
            "Pod/Assets/*.png"
        ]
    },
    "frameworks": "UIKit",
    "dependencies": {
        "hpple": [
            "~> 0.2"
        ],
        "SDWebImage": [
            "~> 3.7"
        ]
    }
}

Pin It on Pinterest

Share This