Skip to content

An Objective-C category to add HTML import to NSMutableAttributedString for UIKit, similar to the initWithHTML methods from OS X's AppKit.

Notifications You must be signed in to change notification settings

cguess/NSMutableAttributedString-HTML

Repository files navigation

NSMutableAttributedString+HTML

A category on NSMutableAttributedString to add HTML features for UIKit that normally only available in AppKit The OSX documentation is here

Originally extracted from Push

Usage

#import "NSMutableAttributedString+HTML.h"
NSString * htmlString = @"This is a <a href=\"http://www.example.com\">sample</a> html file";
NSMutableAttributedString * bodyAttributedText = [[NSMutableAttributedString alloc]
                                                   initWithHTML:[htmlString dataUsingEncoding:NSUTF8StringEncoding]
                                                   documentAttributes:nil];

NSString * htmlStringWithoutBaseURL = @"This is a <a href=\"/test/url\">sample</a> html file";
NSMutableAttributedString * bodyAttributedText = [[NSMutableAttributedString alloc]
                                                   initWithHTML:[htmlStringWithoutBaseURL dataUsingEncoding:NSUTF8StringEncoding]
                                                   baseURL:@"http://www.example.com"
                                                   documentAttributes:nil];

Contact

Christopher Guess cguess@gmail.com

About

An Objective-C category to add HTML import to NSMutableAttributedString for UIKit, similar to the initWithHTML methods from OS X's AppKit.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published