iphone - How to draw string in other device orientations using CGContext iOS -


i'm trying draw text on iphone, in landscape mode, home button on left. need somehow twist numbers (i'm guessing use transform) ?

here's have now:

    cgcontextsetrgbfillcolor(context, 1.0, 0, 0, 1.0);     cgcontextsetrgbstrokecolor(context, 1.0, 0.0, 0.0, 1.0);     cgcontextselectfont(context, "helvetica", 20, kcgencodingmacroman);     cgcontextsettextmatrix(context, cgaffinetransformmakerotation(m_pi/2));     cgcontextsettextdrawingmode(context, kcgtextfill);     nsstring *t = [nsstring stringwithformat:@"%i",seconds];     const char *str=[t utf8string];     cgcontextshowtextatpoint(context,6.0,15.0,str,strlen(str)); 

what need add rotate text can read when phone landscape home button on left.

you have apply 2 transformation matrices. first 1 flip text , second 1 rotate it. try following code:

cgcontextsetrgbfillcolor(context, 1.0, 0, 0, 1.0); cgcontextsetrgbstrokecolor(context, 1.0, 0.0, 0.0, 1.0); cgcontextselectfont(context, "helvetica", 20, kcgencodingmacroman); cgaffinetransform xform = cgaffinetransformmake(                                                 1.0,  0.0,                                                 0.0, -1.0,                                                 0.0,  0.0); cgcontextsettextmatrix(context, xform); cgcontextconcatctm(context, cgaffinetransformmakerotation(m_pi_2)); cgcontextsettextdrawingmode(context, kcgtextfill); nsstring *t = [nsstring stringwithformat:@"%i",seconds]; const char *str=[t utf8string]; cgcontextshowtextatpoint(context,6.0,15.0,str,strlen(str)); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -