Ideas:
1.new an Empty suffix of. txt file, the contents of the essay copy a paragraph
2. Use NSString to receive local files, and then use a title to stitch strings
3. Create a Nsmutableparagraphstyle instance, set the title center, the title distance body interval
4. Create a Nsmutableparagraphstyle instance, set the body to the left, indent each paragraph at the beginning 10
5. Create an instance of the base animation, end with Agent listener animation
Don't talk more about the code
#pragmaMark--Stitching character-(void) LoadData: (NSString *) FileName {//First paragraphNsmutableparagraphstyle *first =[[Nsmutableparagraphstyle alloc]init]; First.alignment=Nstextalignmentcenter; First.linespacing=Ten; //a second paragraphNsmutableparagraphstyle *second =[[Nsmutableparagraphstyle alloc]init]; //start writing from leftSecond.alignment =Nstextalignmentleft; //First Line IndentSecond.firstlineheadindent =Ten; //spacingSecond.linespacing =Ten; Uifont*titlefont = [Uifont systemfontofsize: -]; Uifont*contextfont = [Uifont systemfontofsize: -]; Nsmutableattributedstring*STR1 = [[nsmutableattributedstring alloc]initwithstring:@"game Licensing and service agreements"Attributes:@{nsparagraphstyleattributename:first,nsfontattributename:titlefont}]; //title stitching body, body before adding line breakNSString *str = [NSString stringWithFormat:@"\n%@", filename]; Nsmutableattributedstring*STR2 =[[Nsmutableattributedstring alloc]initwithstring:str Attributes:@{nsparagraphstyleattributename:second, Nsfontattributename:contextfont}]; [Str1 APPENDATTRIBUTEDSTRING:STR2]; _textview.attributedtext=str1;}#pragmaMark--Close the animation-(void) Closeaniamtion: (UIView *) View {cabasicanimation*animation =[cabasicanimation animation]; Animation.keypath=@"Transform.scale"; Animation.tovalue= @0.9; Animation.duration=0.4; Animation.Delegate=Self ; Animation.removedoncompletion=NO; Animation.fillmode=kcafillmodeforwards; [View.layer addanimation:animation Forkey:@"closeanimation"];}#pragmaMark-Local TXT file content-(NSString *) FileName {//Local TXT fileNSString *path = [[NSBundle mainbundle]pathforresource:@"When it's time, it's still good ."Oftype:nil]; //Remove ContentNSString *filename =[[NSString Alloc]initwithcontentsoffile:path encoding:nsutf8stringencoding Error:nil]; returnfilename;}
#pragma mark-agent listener Animation stop-(void) Animationdidstop: (caanimation *) Anim finished: (BOOL) Flag { if ([_bgview.layer animationforkey:@ "closeanimation"] = = anim) { [_bgview Removefromsuperview];} }
Complete code on GitHub, point me to download
iOS Learning-23 Load Local TXT file, nsmutableparagraphstyle paragraph format, zoom animation