2013-08-27 20 views
1

我已經使用下面的代碼片段來製作對象動畫。UIViewAnimationCurveEaseOut,部署彈性效果ios

[UIView animateWithDuration:0.3 delay:0.2 
    options:(UIViewAnimationCurveEaseOut|UIViewAnimationOptionAllowUserInteraction) 
    animations:^{[UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(faceRight:finished:context:)]; 
    self.viewMiniDetalhe.center = CGPointMake(500, 150); 
}completion:^(BOOL finished){ 
    NSLog(@"Move to left done"); 
}]; 

但是我想實現一種彈性效果,稱爲easeOutElastic。

ATT,

+0

您對此有何評論?爲什麼在動畫塊中使用'setAnimationDidStopSelector' - 完成塊有什麼問題? – Wain

+1

這個塊確實是對的,我只是想改變動畫的風格。 在抵達時會產生彈性效果 – leedream

回答

3

如果您對iOS7,還有的[UIView animateWithDuration: delay: usingSpringWithDamping: initialSpringVelocity: options: animations: completion:]類方法。
您可以像彈簧一樣爲您的視圖設置動畫,並設置一些額外的參數,如阻尼和初始速度。

設置damping < 1.0具有彈性行爲。它越小,感覺越好。

initialSpringVelocity只是發射時的速度等於一秒鐘內行進的距離。

如果你想知道更多,here's the documentation

[UIView animateWithDuration: 2.0f delay: 0.0f usingSpringWithDamping: 0.5f initialSpringVelocity: 1.0f options:UIViewAnimationOptionAllowAnimatedContent animations: 
{ 
    myView.frame = CGRectMake(20, 20, myView.frame.size.width, myView.frame.size.height); 
}completion:nil];