Latest 1.1.0
Homepage https://github.com/winddpan/CSLabel
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit, Foundation
Authors

HTML -> TextKit

Usage

NSString *html = @"<p><img src="https://www.baidu.com/img/bdlogo.png"></p>"
"<p><a href="http://www.baidu.com">baidu</a></p>"
"<p>the last paragraph!</p>";

CSHTMLTextAttachmentSerializerName *attachmentSerializer = [CSHTMLTextAttachmentSerializerName new];
attachmentSerializer.placeholderImage = ...;
attachmentSerializer.failedImage = ...;

CSLabel *label = ...
label.delegate = self;
[label setHTML:html withAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:17],
NSForegroundColorAttributeName : [UIColor grayColor],
CSHTMLTextAttachmentSerializerName : attachmentSerializer}];

Support html

  • strong / b
  • em / i
  • strike
  • u
  • sub
  • sup
  • ul ol li
  • img
  • table

Attributes usage

  • You can use CSHTMLTextAttachmentSerializerName class to set downloading/failed image placeholder
  • Support all CoreText attribute such like NSFontAttributeName, NSForegroundColorAttributeName and so on

Author

winddpan, [email protected]

License

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

Latest podspec

{
    "name": "CSLabel",
    "version": "1.1.0",
    "summary": "HTML -> TextKit displayer.",
    "description": "AttributedString displayer view.",
    "homepage": "https://github.com/winddpan/CSLabel",
    "license": "MIT",
    "authors": {
        "winddpan": "[email protected]"
    },
    "source": {
        "git": "https://github.com/winddpan/CSLabel.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "CSLabel/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "libraries": "xml2",
    "xcconfig": {
        "HEADER_SEARCH_PATHS": ""${SDK_DIR}/usr/include/libxml2""
    }
}

Pin It on Pinterest

Share This