Graphics Reference
In-Depth Information
Figure 5.15 Nested layers with opposite transforms applied
Note how the negative 45-degree rotation of the inner layer cancels out the 45-degree
rotation of outer layer so that the inner layer is pointing the right way up.
Logically, if an inner layer has the opposite transform to its outer layer (in this case,
a rotation about the Z axis), then we would expect the two transforms to cancel each
other out.
Let's verify that this is the case in practice. Listing 5.7 shows the code to do this, and
Figure 5.16 shows the result.
Listing 5.7 Opposite Rotation Transforms Around Z Axis
@interface ViewController ()
@property ( nonatomic , weak ) IBOutlet UIView *outerView;
@property ( nonatomic , weak ) IBOutlet UIView *innerView;
@end
@implementation ViewController
- ( void )viewDidLoad
{
[ super viewDidLoad ];
//rotate the outer layer 45 degrees
CATransform3D outer = CATransform3DMakeRotation ( M_PI_4 , 0 , 0 , 1 );
Search WWH ::




Custom Search