使视图显示并在按钮中消失

时间:2015-11-02 17:53:36

标签: ios objective-c animation uiview

我希望在点击按钮(向上滑动和缩放)之外显示一个视图,然后再点击再次以相同的方式消失到该按钮。我已经使用此代码从按钮中获得了一个视图。但逆转是行不通的。任何帮助

- (IBAction) arrowBtnClick{

    _arrowUpBtn.enabled=false;
    if (_isSliderMenuPresent) {
        [UIView animateWithDuration:.5f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{
            _sliderView.frame = CGRectMake(_sliderView.frame.origin.x, 440.0f, _sliderView.frame.size.width, 200 );
        } completion:^(BOOL finished)
         {
             _isSliderMenuPresent = false;
             _sliderView.hidden = true;
             _arrowUpBtn.enabled=true;
             [_arrowUpBtn setBackgroundImage:[UIImage imageNamed:@"arrow_up.png"] forState:UIControlStateNormal];
         }];
    }
    else{
        _sliderView.hidden = false;
        _sliderView.transform = CGAffineTransformMakeScale(0.00, 0.00);
        [UIView animateWithDuration:.5f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
            _sliderView.transform = CGAffineTransformIdentity;
            _sliderView.frame = CGRectMake(_sliderView.frame.origin.x,_sliderView.frame.origin.y-150, _sliderView.frame.size.width, 200 );
        } completion:^(BOOL finished)
         {
             _isSliderMenuPresent = true;
             _arrowUpBtn.enabled=true;
             [_arrowUpBtn setBackgroundImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateNormal];
         }];
    }   
}

0 个答案:

没有答案