2015-09-11 104 views
1

我彈出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

而不是使用一個轉換,簡單的變化框架。 – rmaddy

回答

0

試試這個:

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