Ios 滑动视图动画

Ios 滑动视图动画,ios,uiviewanimation,Ios,Uiviewanimation,我有一个按钮,在按钮操作中,我想通过从按钮滑动来显示我的UITableView,在单元格单击后,它应该通过滑动效果向上移动。我通过UIViewAnimation来实现,通过设置固定的y位置并将高度从0更改为高度 tableview.hidden=FALSE; tableview.frame = CGRectMake(0,myButton.frame.size.height,myButton.frame.size.width, 0); [UIVie

我有一个按钮,在按钮操作中,我想通过从按钮滑动来显示我的UITableView,在单元格单击后,它应该通过滑动效果向上移动。我通过UIViewAnimation来实现,通过设置固定的y位置并将高度从0更改为高度

       tableview.hidden=FALSE;
        tableview.frame = CGRectMake(0,myButton.frame.size.height,myButton.frame.size.width, 0);


        [UIView animateWithDuration:AnimationTime animations:^{

              tableview.frame = CGRectMake(tableview.frame.origin.x, tableview.frame.origin.x, tableview.frame.size.width,  200 );


        } completion:^(BOOL finished) {


        }];

但这不是。我想要一个滑动效果。任何帮助都将是可观的。

使用此方法制作动画<代码>为动画样式提供一个选项。
在objective-c中有很多动画样式选项

[UIView animateWithDuration:15.0f delay:0.0f options:UIViewAnimationOptions animations:^{
        tableview.frame = CGRectMake(tableview.frame.origin.x, tableview.frame.origin.x, tableview.frame.size.width,  200 );
    } completion:^(BOOL finished)
     {

     }];
对于您的案例,我认为您应该使用
UIViewAnimationOptionTransitionFlipFromTop
作为从上到下滑动桌子的动画选项。通过使用此选项,您的桌子视图可以在15秒内获得完整高度。你也能做到

编辑:

一旦你们点击了单元格,你们就会希望你们的tableview显示幻灯片效果。比使用

[UIView animateWithDuration:2.0f delay:0.0f options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
            tableview.frame = CGRectMake(tableview.frame.origin.x, tableview.frame.origin.x, tableview.frame.size.width,  0 );
        } completion:^(BOOL finished)
         {

         }];

for slide up animation. 

问题不是动画,问题是您正在定义的帧。最简单的方法是定义“打开”和“关闭”帧,并使用它们设置动画。。见下文

定义打开和关闭框架

-(void)initComponents{
    CGRect rect=tableView.frame;

    rect.origin=myButton.center;

    openFrame=rect;//Assign openFrame before changing the size.

    rect.size=CGSizeZero;
    tableView.frame=rect;

    closeFrame=rect;//Assign closeFrame
}
调用
viewDidLoad
中的
initComponents
函数来设置
表格视图的初始状态。现在只需在您要调用的操作上使用下面的函数

-(void)openMenu{
   [UIView animateWithDuration:.3 animations:^{
        tableView.frame=openFrame;
    }];
}

-(void)closeMenu{
   [UIView animateWithDuration:.3 animations:^{
        tableView.frame=closeFrame;
    }];
}
就这样。它应该会起作用


让我知道。干杯。

像菜单一样,从顶部滑动和隐藏向上滑动?是的。这就是我想要的。我也使用了与您使用的方法相同的方法,而不是相同的方法。在这个方法中,您有一个额外的参数选项:可以用于动画样式。对不起,我没有理解您。请您详细解释一下。我不知道如何使用itsorry进行后期回放。没有更改。这与滑动不同。假设有5个单元格,如果其向下滑动,则在向下滑动期间,clle 5应始终可见