开发者

Iphone 3d Animation

I recently posted my problem but neither did I get an answer here or elsewhere, nor can I find my post again... Anyway, I want to try to state my point clearer, hoping you can help me this time maybe.

The part of code, this is about, looks like this:

CABasicAnimation *animation = nil; 
CATransform3D transform;

animation = [CABasicAnimation animationWithKeyPath:@"transform"];

transform = CATransform3DMakeRotation(1.57f, 0.0f, 1.0f, 0.0f); 
value = [NSValue valueWithCATransform3D:transform]; 
[animation setToValue:value];
[animation setAutoreverses:YES]; 
[animation setDuration:0.5f];
[[shieldView layer] addAnimation:animation forKey:@"180"];

What happens, is that I have a UIImageView with an image in it. I take this View and rotate it around the z-Axis for half a turn (1.57 measured in arc).

Now there is another View overlapping with the one being transformed in 3d. This leads to my problem: As soon as the transformation is executed, the transformed layer is sort of clipped against the overlapping view, but wrong, so that u see a 'flickering' effect to both Views.

Now I don't know, why this happens. I would expect the view to be animated appropria开发者_运维知识库tely, without this 'bug', and the Views to be just displayed correctly.... since I do not do anything special.

I have tried to overlay 2D transformations, using the 'beginAnimations' and 'commitAnimations' context, which works fine. This means, the problem is sort of hidden in the 3D rotation of my View.

You guys have any clues on this? I hope I explained that well enough.


If these are two sibling views (subviews of the same superview), their layers can overlap, potentially creating the visual artifacts you see. You should be able to either reposition the views relative to one another in the view hierarchy (make one view a level above or below the other) or directly set the Z position of the view's layer. If you do something like

shieldView.layer.zPosition = 1.0f;

your shieldView's layer should be slightly above the other view's layer (unless I'm remembering the coordinate space wrong and it needs to be -1.0f) and you should be able to avoid the clipping you see now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜