Bob*_*aaf 6 iphone core-animation ios catransformlayer
我搜索了谷歌和stackoverflow上的所有帖子,但我根本无法解决这个难题.我正在尝试重新创建现在着名的todo应用'Clear'在添加新任务时所做的效果.他们有某种动画,从顶部新任务出现在某种3D立方体效果中.他们的特殊之处在于,当你仔细观察时,左下角和下角总是停留在同一个地方.
现在我有以下内容:在点0,0设置了一个320x460的UIView,在点(0,-460)设置了一个320x460的UIView.我想要的是顶部的UIView与顶部的Clear相同的立方体效果.这是我到目前为止:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//startLoc is defined globally to remember the first position
startLoc = [[touches anyObject] locationInView:self];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint location = [[touches anyObject] locationInView:self];
float difference = location.y-startLoc.y;
if(diff > 0 && diff < 90)
{
//Init the transform
CATransform3D transform = CATransform3DIdentity;
transform.m34 = perspective;
//Rotate (radians is a degree-to radians function)
transform = CATransform3DRotate(transform, radians(90-diff), 1.0f, 0.0f, 0.0f);
//Also translate the view down
transform = CATransform3DTranslate(transform, 0.0f, 230+diff, 0.0f);
//the 230 is necessary I think for the Anchorpoint but I'm not sure
secondView.layer.transform = transform;
}
Run Code Online (Sandbox Code Playgroud)
}
它以某种方式工作但不正确,一旦我进行旋转,视图变得更大,左下角和右下角都在视图之外.如果我将视图缩小然后再进行3Dscale,它也会搞砸了.通过正确设置图层的zPosition,我已经解决了一半图像消失的问题,但这是我得到的.我试图使用其他项目的代码,但他们的3D立方体效果与"清除"应用程序不同.唯一接近的是iCarousel项目,但我无法使用应用程序中的正确代码,我无法让它工作.有人能帮我吗?
归档时间: |
|
查看次数: |
2712 次 |
最近记录: |