Loading rtfd files with Uitextview
Effect
Description
This method can be used to achieve a very simple rich text display effect, including graphic and other effects.
Source
////VIEWCONTROLLER.M//RTFD////Created by youxianming on 15/9/10.//Copyright (c) 2015 Zipeiyi. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () {Uitextview*_textview;}@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; NSString*path = [[NSBundle mainbundle] Pathforresource:@"Demo"OfType:@"RTFD"]; Nsattributedstring*string=[[Nsattributedstring alloc] Initwithfileurl:[nsurl Fileurlwithpath:path] Options:nil Documentattributes:nil Error:nil]; _textview=[[Uitextview alloc] initWithFrame:self.view.bounds]; _textview.backgroundcolor=[Uicolor Clearcolor]; _textview.attributedtext=string; _textview.editable=NO; _textview.selectable=NO; _textview.bounces=YES; _textview.showshorizontalscrollindicator=NO; _textview.showsverticalscrollindicator=NO; [Self.view Addsubview:_textview];}@end
Details
A picture in rich text
Comparison chart
Loading rtfd files with Uitextview