UILabel.transform - Orientation Dependent (support transform on upside down portrait only)

618 Views Asked by At

Im looking for the code necessary to fire my UILabel.transform only on a certain orientation, upside down (with good reason) My universal app only supports portrait orientation, both regular and upside down. So far so good! I have the code needed to transform the label 180 degrees (upside down/reverse text)

.H
#define degreesToRadian(x) (M_PI * (x) / 180.0)
IBOutlet UILabel *Label;

.M
Label.transform = CGAffineTransformMakeRotation(degreesToRadian(180));

The code I would like is:

When in regular portrait (home button on the bottom) the label is normal. When in upside down portrait (home button on top, camera on bottom) the label is transformed.

Thanks in advance!

P.S. Your help on this is going to a notable good cause that I would love to share when it's complete (few days away)

1

There are 1 best solutions below

7
rob mayoff On BEST ANSWER

You need to override willAnimateRotationToInterfaceOrientation:duration: in your UIViewController subclass. In that method, you can check the new interface orientation and set the label's transform appropriately.