Flipped NSString drawing in CGContext

后端 未结 2 1745
天涯浪人
天涯浪人 2020-12-17 04:32

I try to draw a string in this texture:

http://picasaweb.google.it/lh/photo/LkYWBv_S_9v2d6BAfbrhag?feat=directlink

but the green numbers seem vertical flippe

2条回答
  •  一整个雨季
    2020-12-17 05:31

    Better save the text 's matrix before draw, otherwise it will affect other text draw by CoreGraphic:

    CGContextSaveGState(ctx);
    CGAffineTransform save = CGContextGetTextMatrix(ctx);
    CGContextTranslateCTM(ctx, 0.0f, self.bounds.size.height);
    CGContextScaleCTM(ctx, 1.0f, -1.0f);
    [str drawAtPoint:point withFont:font];
    CGContextSetTextMatrix(ctx, save);
    CGContextRestoreGState(ctx);
    

提交回复
热议问题