2

I want to have a completely upside down interface. I don't mean it should change according to the orientation of the phone. I mean it should be upside down ( UIInterfaceOrientationPortraitUpsideDown ) the whole time. A button should be able to 'right' it again. The same button should return everything to upside down.

What's the best way of achieving this?

cannyboy
  • 24,180
  • 40
  • 146
  • 252

3 Answers3

2

Set the transform attribute on the root view's layer. Something like:

bool upsideDown = ...
float degrees = upsideDown ? 180.0f : 0.0f;
NSNumber* radians = [NSNumber numberWithFloat:degrees * M_PI / 180.0f];
[rootView.layer setValue:radians forKeyPath:@"transform.rotation.z"];

(Of course, you could easily optimize out the little formula converting from degrees to radians since you only use 0.0 and pi. Included it just for clarity.)

Felixyz
  • 19,053
  • 14
  • 65
  • 60
2

If you want an upside-down interface, orientation does not matter. In essence, apply a rotated affine transform to the view you use, such as:

window.transform = CGAffineTransformRotate(window.transform, M_PI);

Some offset will be required there if you have a status bar up there. Apply that again and you "rotate" it back.

lukhnos
  • 116
  • 6
1

I would look into two options:

  1. Rotating the Canvas 180 degrees
  2. Inverting the accelerometer

Not sure how to accomplish either task, but a quick Google search displayed some results.

Community
  • 1
  • 1
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383