ios - NSAttributedString drawInRect disappears when the frame is offset -
i have strange problem. when offset frame/rect use draw nsattributedstring
my text disappears. ideas why? here image simple offset of 40 px.
r.size = [self.text boundingrectwithsize:r.size options:nsstringdrawinguseslinefragmentorigin context:nil].size; r.origin.y +=40; [[uicolor orangecolor] setfill]; cgcontextfillrect(ctx, r); [self.text drawinrect:r]; result:

and here without offset. 
how draw attributedtext @ given offset?
i don't know why question has not yet been addressed. serious issue nsattributedstring api hope apple acknowledges soon, either in documentation or patching implementation.
for time being, can work around issue translating graphics context before drawing string.
cgcontextref context = whatever; cgcontextsavegstate(context); cgcontexttranslatectm(context, x, y); // draw here cgcontextrestoregstate(context);
Comments
Post a Comment