Ios 我想在单击按钮时设置UITableView的动画

Ios 我想在单击按钮时设置UITableView的动画,ios,objective-c,uitableview,uiviewanimation,Ios,Objective C,Uitableview,Uiviewanimation,我有UITableView,我想在用户单击按钮时设置动画 对于所选状态-->自下而上 对于未选择的状态-->从上到下 为此,我尝试了以下代码。 我的桌面视图框架(0,39,宽度,高度) 当我点击按钮时,它将正确地从底部到顶部设置动画。 但当我再次单击按钮时,它将再次从底部转到顶部 因为您已将tableview的frame.origin.y设置为-y或XY坐标 self.tblVWInviteFriend.frame = CGRectMake(0, -[UIScreen mainScree

我有
UITableView
,我想在用户单击按钮时设置动画

对于所选状态-->自下而上

对于未选择的状态-->从上到下

为此,我尝试了以下代码。 我的桌面视图框架(0,39,宽度,高度)

当我点击按钮时,它将正确地从底部到顶部设置动画。
但当我再次单击按钮时,它将再次从底部转到顶部

因为您已将tableview的
frame.origin.y
设置为-y或XY坐标

    self.tblVWInviteFriend.frame = CGRectMake(0, -[UIScreen mainScreen].bounds.size.height, self.tblVWInviteFriend.frame.size.width, self.tblVWInviteFriend.frame.size.height);
换成这个

    self.tblVWInviteFriend.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height, self.tblVWInviteFriend.frame.size.width, self.tblVWInviteFriend.frame.size.height);
试试这个:

- (IBAction)onInviteFriendsButtonClick:(UIButton *)sender {
    sender.selected =! sender.selected;

    if (sender.selected) {
        CGRect napkinBottomFrame = txtAOP.frame;
        napkinBottomFrame.origin.y = [UIScreen mainScreen].bounds.size.height;
        txtAOP.frame = napkinBottomFrame;
        [UIView animateWithDuration:0.5 delay:0.0 options: UIViewAnimationOptionTransitionCurlUp animations:^{
            txtAOP.frame = CGRectMake(0, 39, txtAOP.frame.size.width, txtAOP.frame.size.height);
        } completion:^(BOOL finished){/*done*/}];
    }
    else {
        CGRect napkinBottomFrame = txtAOP.frame;
        napkinBottomFrame.origin.y = -[UIScreen mainScreen].bounds.size.height;
        txtAOP.frame = napkinBottomFrame;
        [UIView animateWithDuration:0.5 delay:0.0 options: UIViewAnimationOptionTransitionCurlDown animations:^{
            txtAOP.frame = CGRectMake(0,39 , txtAOP.frame.size.width, txtAOP.frame.size.height);
        } completion:^(BOOL finished){/*done*/}];
    }
}
- (IBAction)onInviteFriendsButtonClick:(UIButton *)sender {
    sender.selected =! sender.selected;

    if (sender.selected) {
        CGRect napkinBottomFrame = txtAOP.frame;
        napkinBottomFrame.origin.y = [UIScreen mainScreen].bounds.size.height;
        txtAOP.frame = napkinBottomFrame;
        [UIView animateWithDuration:0.5 delay:0.0 options: UIViewAnimationOptionTransitionCurlUp animations:^{
            txtAOP.frame = CGRectMake(0, 39, txtAOP.frame.size.width, txtAOP.frame.size.height);
        } completion:^(BOOL finished){/*done*/}];
    }
    else {
        CGRect napkinBottomFrame = txtAOP.frame;
        napkinBottomFrame.origin.y = -[UIScreen mainScreen].bounds.size.height;
        txtAOP.frame = napkinBottomFrame;
        [UIView animateWithDuration:0.5 delay:0.0 options: UIViewAnimationOptionTransitionCurlDown animations:^{
            txtAOP.frame = CGRectMake(0,39 , txtAOP.frame.size.width, txtAOP.frame.size.height);
        } completion:^(BOOL finished){/*done*/}];
    }
}