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:

enter image description here

and here without offset. enter image description here

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

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -