I have a CALayer added and transformed the following way. I would assume that translating the layer by any constant before rotation should not have an effect on rotation around Y axis but it seems to make a difference, what am I missing here ?
- (void)viewDidAppear:(BOOL)animated
{
CALayer* layer = [CALayer layer];
layer.bounds = self.img1.bounds;
layer.backgroundColor = [[UIColor grayColor] CGColor];
layer.anchorPoint = CGPointMake(0, 0.5);
layer.position = CGPointMake(0, CGRectGetMidY(self.view.bounds));
layer.contents = (id)[self.img1.image CGImage];
layer.transform = [self transformforView1];
[self.view.layer addSublayer:layer];
}
Rotation without any translation and output:
- (CATransform3D)transformforView1
{
CATransform3D t = CATransform3DIdentity;
t.m34 = 1.0/-700;
t = CATransform3DTranslate(t, 0, 0, 0);
t = CATransform3DRotate(t, degToRad(45), 0, 1, 0);
return t;
}
Same rotation with translation of 500 and output:
- (CATransform3D)transformforView1
{
CATransform3D t = CATransform3DIdentity;
t.m34 = 1.0/-700;
t = CATransform3DTranslate(t, 500, 0, 0);
t = CATransform3DRotate(t, degToRad(45), 0, 1, 0);
return t;
}