2つの画像を回転させたいのですが、一方の画像をもう一方の画像の後ろに配置しますが、次のコードで画像を回転すると、背面の画像が前面の画像の上になり、ZPOを割り当てますが、変更はありません
回転する前の私のビューのこのリンクhttp://i39.tinypic.com/ivv2ah.png
回転した後http://i43.tinypic.com/ic05xj.png
これがどのように起こるか
[UIView animateWithDuration:0.2 animations:
^{
CALayer *myLayer=self.image2.layer;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animation.fromValue = [NSNumber numberWithFloat:(1 * M_PI/Down)];
animation.toValue = [NSNumber numberWithFloat:(1 * M_PI/UP)];
animation.repeatCount =0;
animation.duration=0.2;
[animation setRemovedOnCompletion:NO];
animation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionLinear];
[self.image2.layer addAnimation:animation forKey:@"transform.rotation.x"];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = (1/500.0f);
transform = CATransform3DRotate(transform, (1 * M_PI/UP), 1, 0,0);
myLayer.transform=transform;
}
completion:^(BOOL finished)
{
self.image2.postion=@"UP";
}];
[UIView animateWithDuration:0.2 animations:
^{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animation.fromValue = [NSNumber numberWithFloat:(1 * M_PI/Down)];
animation.toValue = [NSNumber numberWithFloat:(1 * M_PI/UP)];
animation.repeatCount =0;
animation.duration=0.2;
[animation setRemovedOnCompletion:NO];
animation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionLinear];
[card.layer addAnimation:animation forKey:@"transform.rotation.x"];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = (1/500.0f);
transform = CATransform3DRotate(transform, (1 * M_PI/UP), 1, 0,0);
card.layer.transform=transform;
}
completion:^(BOOL finished)
{
card.postion=@"UP";
}];
CArdImageはカスタムUIImageViewであり、これは私が変更するものです
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.layer.anchorPoint=CGPointMake(0.5, 1.0);
CATransform3D transform = CATransform3DIdentity;
transform.m34 = (1/500.0f);
transform = CATransform3DRotate(transform, (1 * M_PI/2.5), 0.5, 0,0);
self.layer.transform=transform;
self.postion=@"UP";
}
return self;
}