iOS Learning-23 Load Local TXT file, nsmutableparagraphstyle paragraph format, zoom animation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.