使用动画关闭视图

时间:2015-09-11 14:06:25

标签: ios objective-c animation

我正在使用反弹动画弹出couponDetailsView。但我想从左到右动画中忽略视图。我怎样才能做到这一点?以下是我的源代码。任何形式的帮助都会非常有用。

#pragma mark Bounce Animation


-(void) openContentDetailsView
{

    [self.view bringSubviewToFront:self.couponDetailsView];

    [UIView animateWithDuration:0.2 animations:
     ^(void){
         self.couponDetailsView.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.1f, 1.1f);
         self.couponDetailsView.alpha = 0.5;
     }
                     completion:^(BOOL finished){
                         [self bounceOutAnimationStoped];
                     }];

}


- (void)bounceOutAnimationStoped
{
    [UIView animateWithDuration:0.1 animations:
     ^(void){
         self.couponDetailsView.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.9, 0.9);
         self.couponDetailsView.alpha = 0.8;
     }
                     completion:^(BOOL finished){
                         [self bounceInAnimationStoped];
                     }];
}
- (void)bounceInAnimationStoped
{
    [UIView animateWithDuration:0.1 animations:
     ^(void){
         self.couponDetailsView.transform = CGAffineTransformScale(CGAffineTransformIdentity,1, 1);
         self.couponDetailsView.alpha = 1.0;
     }
                     completion:^(BOOL finished){
                         [self animationStoped];
                     }];
}
- (void)animationStoped
{


}
- (IBAction)contentDetailsCloseButtonAction:(id)sender {

    self.couponDetailsView.alpha = 0;
    self.couponDetailsView.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.6, 0.6);

}

1 个答案:

答案 0 :(得分:0)

试试这个:

    [UIView animateWithDuration:0.3f
                  delay:0.0f
                options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
             animations:^{
                 [testView setFrame:CGRectMake(x, y, width, height)];
} completion:^(BOOL finished) {
     [testView removeFromSuperview]; 
}];