ios - Change drawRect output depending on device orientation -


i want use drawrect draw 6 boxes used background output of 6 labels have setup - when device's orientation changed need change boxes drawn... thinking of doing if-else statement below:

- (void)drawrect:(cgrect)rect { // drawing code if (uiinterfaceorientationisportrait(orientation)) {     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetrgbfillcolor(context, 0.611, 0.505, 0.321, 1.0); // goldie brown colour     cgcontextfillrect(context, cgrectmake(70, 277, 35, 50)); // years     cgcontextfillrect(context, cgrectmake(145, 277, 35, 50)); // months     cgcontextfillrect(context, cgrectmake(220, 277, 35, 50)); // days     cgcontextfillrect(context, cgrectmake(70, 393, 35, 50)); // hours     cgcontextfillrect(context, cgrectmake(145, 393, 35, 50)); // minutes     cgcontextfillrect(context, cgrectmake(220, 393, 35, 50)); // seconds } else {     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetrgbfillcolor(context, 0.611, 0.505, 0.321, 1.0); // goldie brown colour     cgcontextfillrect(context, cgrectmake(87, 221, 35, 50)); // years     cgcontextfillrect(context, cgrectmake(162, 221, 35, 50)); // months     cgcontextfillrect(context, cgrectmake(234, 221, 35, 50)); // days     cgcontextfillrect(context, cgrectmake(308, 221, 35, 50)); // hours     cgcontextfillrect(context, cgrectmake(385, 221, 35, 50)); // minutes     cgcontextfillrect(context, cgrectmake(466, 221, 35, 50)); // seconds  } 

but wont work because (uiinterfaceorientationisportrait(orientation)) needs parameter/constant declaring & doesnt can here - there similar can do?

you can either using

if(uiinterfaceorientationisportrait([[uiapplication sharedapplication] statusbarorientation])) 

or changing flag (e.g. bool shoulddrawportrait) in didrotatefrominterfaceorientation: of view controller.


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 -