ios - NSTextAttachment doesn't show on CATextLayer -


i tried on uitextview work. image left blank when use catextlayer.

anyone tried before?

here code tried in uiview drawrect

nstextattachment* attachment = [nstextattachment new]; attachment.image = [uiimage imagenamed:@"rainbow.png"]; nsattributedstring* imagestring = [nsattributedstring attributedstringwithattachment:attachment]; nsdictionary * attribute = @{nsfontattributename: [uifont fontwithname:@"helvetica" size:12]}; nsmutableattributedstring *speechstring = [[nsmutableattributedstring alloc] initwithstring: @"hi" attributes:attribute]; [speechstring insertattributedstring:imagestring atindex:1]; [speechstring appendattributedstring:imagestring]; 

then add catextlayer

catextlayer * speechtextlayer = [catextlayer layer]; [speechtextlayer setstring:speechstring]; [speechtextlayer setframe:self.bounds]; [speechtextlayer setbackgroundcolor:[uicolor whitecolor].cgcolor]; [self.layer addsublayer:speechtextlayer]; 


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -