2017-06-23 5 views
0

私はUITableViewを持っています。ユーザーがボタンをクリックしたときにアニメートしたいと思います。選択された状態のためにボタンクリックでUITableViewをアニメーション化したい

- >非選択状態の場合

を先頭にBOTTOM - >私はコードの下にしようとしたことについてはBOTTOM

TO TOP。 私のテーブルビューフレーム(0.39、幅、高さ)

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

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

私はそれが適切トップへBOTTOMからアニメーション化します]ボタンをクリックしてください。 ボタンをもう一度クリックすると、もう一度ボトムからに移動します。

答えて

0

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); 
0

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*/}]; 
    } 
} 
関連する問題