我有滚动视图,在滚动视图中有两个视图为MainView,另一个视图为SideMenuView。
我想让动画像下面这样。

知道该怎么做才能让这件事奏效吗?
发布于 2016-08-02 12:56:33
Psuedo代码如下:
- (void)animateSideMenu{
homeView.frame = CGRectMake(sideMenuWidth, 0.0, (self.view.frame.size.width - sideMenuWidth), self.view.frame.size.height);
[UIView animateWithDuration:1.0 delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
sideMenu.frame = CGRectMake(0.0, 0.0, sideMenuWidth, sideMenuHeight);
[self flipAnimation];
} completion:^(BOOL finished) {
}];
}
- (void)flipAnimation{
CABasicAnimation *yRotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
yRotate.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2, 0, 1, 0)];
yRotate.toValue = @(M_PI * 1.5);
yRotate.duration = 0.5;
yRotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[sideMenu.layer addAnimation:yRotate forKey:@"yRotate"];
}以下是开发这种类型动画的步骤:
试试看,如果有什么事情发生,请告诉我。
发布于 2016-08-03 21:15:18
我不会使用滚动视图,而是使用UIPanGestureRecognizer来检测当前的"pan偏移量“,并计算这两个视图的当前动画部分和位置(让我们简化它,使菜单成为view1和rest view2)。然后,我将简单地在.Changed状态中设置一个适当的转换。在.Ended状态下,我将查看菜单是更接近打开还是关闭,并创建相应设置为.toValue的动画。您应该使用CAAnimations或更好的- 脸谱流行动画,因为您可以暂停并删除它们,视图保持不变,而不是跳转到它们的初始位置(就像UIViewAnimate的情况一样)。
如果你需要帮助写精确的代码,你可以在这里写,我会编辑我的答案。
发布于 2016-08-04 03:08:18
该菜单有教程,尽管它在Swift:https://www.raywenderlich.com/87268/3d-effect-taasky-swift中
https://stackoverflow.com/questions/38583290
复制相似问题