Rich text renderer implemented by CoreText.
- Add the source files
JX_RichTextRenderer.h
andJX_RichTextRenderer.m
to your Xcode project. - Import
JX_RichTextRenderer.h
. - Create a
JX_RichTextRenderer
instance:
JX_RichTextRenderer *richTextRenderer = [[JX_RichTextRenderer alloc] initWithAttributedText:attributedString
constraintSize:CGSizeMake(200, CGFLOAT_MAX)
insets:UIEdgeInsetsZero
lineSpace:0];
- Get content size:
CGSize contentSize = richTextRenderer.contentSize;
- Get content image:
UIImage *richTextImage = [richTextRenderer render];
- Use the image as you want.
You can add or remove functions as you need.
This component requires iOS 8.0+
.
JX_RichTextRenderer is provided under the MIT license. See LICENSE file for details.