iphone - Can I use NSAttributedString in Core Text in iOS? -
i'm trying work out how take nsattributedstring , use in core text on ipad. watched 1 of wwdc videos (110) has slides (but no source code) , describes how create nsattributedstring, put ctframesetterref:
ctfontref helveticabold = ctfontcreatewithname( cfstr("helvetica-bold"), 24.0, null); nsstring* unicodestring = nslocalizedstring(@"titlestring", @"window title"); cgcolorref color = [uicolor bluecolor].cgcolor; nsnumber* underline = [nsnumber numberwithint:kctunderlinestylesingle|kctunderlinepatterndot]; nsdictionary* attributesdict = [nsdictionary dictionarywithobjectsandkeys:helveticabold, (nsstring*)kctfontattributename, color, (nsstring*)kctforegroundcolorattributename, underline, (nsstring*)kctunderlinestyleattributename, nil]; nsattributedstring* stringtodraw = [[nsattributedstring alloc] initwithstring:unicodestring attributes:attributesdict]; ctframesetterref framesetter = ctframesettercreatewithattributedstring(stringtodraw); ctframeref frame = ctframesettercreateframe(framesetter, cfrangemake(0, 0), path, null); cfrelease(framesetter); ctframedraw(frame, context); cfrelease(frame);
but when try this, throws error:
passing argument 1 of 'ctframesettercreatewithattributedstring' incompatible pointer type
are cfattributedstring , nsattributedstring 'toll-free bridged'? i've read somewhere true on osx, how apple in demo...
thanks!
:-joe
you can download wwdc10 source code here. in addition, use toll-free bridging , explicitly cast stringtodraw
cfattributedstringref
.
Comments
Post a Comment