/** String Animation written @param string to be written @param view parent view @param ui_font font size @param color font*/- (void) Createanimationlayerwithstring: (nsstring*)stringAndview: (UIView *) View Andfont: (uifont*) Ui_font Andstrokecolor: (uicolor*) color{ctfontref font=ctfontcreatewithname (cfstringref) ui_font.fontname, Ui_font.pointsize, NULL); Cgmutablepathref Letters=cgpathcreatemutable (); //This sets the font and size of the drawing lineNsdictionary *attrs =[nsdictionary Dictionarywithobjectsandkeys: (__bridgeID) font, kctfontattributename, nil]; Nsattributedstring*attrstring = [[Nsattributedstring alloc] initwithstring:stringAttributes:attrs]; Ctlineref Line=ctlinecreatewithattributedstring ((cfattributedstringref) attrstring); Cfarrayref Runarray=Ctlinegetglyphruns (line); for(Cfindex Runindex =0; Runindex < Cfarraygetcount (Runarray); runindex++) {Ctrunref run=(ctrunref) cfarraygetvalueatindex (Runarray, Runindex); Ctfontref Runfont=Cfdictionarygetvalue (Ctrungetattributes (run), kctfontattributename); for(Cfindex Runglyphindex =0; Runglyphindex < Ctrungetglyphcount (run); runglyphindex++) {Cfrange Thisglyphrange= Cfrangemake (Runglyphindex,1); Cgglyph Glyph; Cgpoint position; Ctrungetglyphs (Run, Thisglyphrange,&glyph); Ctrungetpositions (Run, Thisglyphrange,&position); Cgpathref Letter=ctfontcreatepathforglyph (Runfont, Glyph, NULL); Cgaffinetransform T=cgaffinetransformmaketranslation (position.x, POSITION.Y); Cgpathaddpath (Letters,&T, letter); Cgpathrelease (letter); }} Cashapelayer*pathlayer =[Cashapelayer layer]; Pathlayer.frame= CGRectMake (0,0, View.frame.size.width, view.frame.size.height); Pathlayer.bounds=Cgpathgetboundingbox (Letters); pathlayer.geometryflipped=YES; Pathlayer.path=letters; Pathlayer.strokecolor=[Color Cgcolor]; Pathlayer.fillcolor=Nil; Pathlayer.linewidth=1.0f; Pathlayer.linejoin=Kcalinejoinbevel; [View.layer Addsublayer:pathlayer]; Cabasicanimation*pathanimation = [Cabasicanimation animationwithkeypath:@"Strokeend"]; Pathanimation.duration=5.0; Pathanimation.fromvalue= [NSNumber numberwithfloat:0.0f]; Pathanimation.tovalue= [NSNumber numberwithfloat:1.0f]; [Pathlayer addanimation:pathanimation Forkey:@"Strokeend"]; Cgpathrelease (Letters); Cfrelease (font); Cfrelease (line);}
iOS value string Dynamic writing