0
我正在使用基於塊的動畫模擬作爲遊戲的介紹動畫的交易卡。動畫效果很好,除非用戶在動畫過程中導致一個segue發射,我們執行額外的動畫以獲得從源到目標視圖控制器的「滑動」轉換。現在發生的事情是,已經被「處理」的卡片適當地滑出屏幕,並且如果有沒有處理過的卡片,它在轉換的中間處理它,然後當目標視圖控制器被按下時卡片消失。這很醜陋。中斷完成塊基於動畫執行單獨的動畫
我已經嘗試'view.layer removeAllAnimations'沒有幫助(我沒有進口quartzcore)。我想要做的是取消完成塊中未完成的動畫,並簡單地執行segue動畫。
這裏的「交易」代碼:
[UIView animateWithDuration:0.20f
delay:0.20f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
_fiveOfHearts.center = CGPointMake(90, 198);
_fiveOfHearts.transform = fiveOfHeartsTransform;
}
completion:^(BOOL finished)
{[UIView transitionWithView:_fiveOfHearts duration:0.20f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
_fiveOfHearts.image = [UIImage imageNamed:@"52"];
}completion:nil];
[UIView animateWithDuration:0.30f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
_jackOfHearts.center = CGPointMake(128, 196);
_jackOfHearts.transform = jackfHeartsTransform;
}
completion:^(BOOL finished)
{[UIView transitionWithView:_jackOfHearts duration:0.40f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
_jackOfHearts.image = [UIImage imageNamed:@"112"];
}completion:nil];
[UIView animateWithDuration:0.30f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
_aceOfHearts.center = CGPointMake(162, 196);
_aceOfHearts.transform = aceOfHeartsTransform;
}
completion: ... and so on.
的賽格瑞代碼看起來是這樣的:
for (UIView *iv in src.view.subviews) {
if (iv.tag != 99999) {
[UIView animateWithDuration:0.5f animations:^{iv.center = CGPointMake(iv.center.x - 600, iv.center.y);}];
}
}
全局你的意思BOOL在某種單一的,我保持在整個應用程序活着? – 2013-03-02 01:02:56
那麼如果你只需要它在VC中,你可以添加它作爲一個屬性,並在該VC中的所有方法中使用它 – 2013-03-02 01:05:06
你也可以使用@property(assign)BOOL varName not(nonatomic,strong) – 2013-03-02 01:23:30