[UIView animateWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>iview
這個函數首先須要animations動畫設置是函數調用當即執行,而延遲的時間是執行completion的。 這裏有一個坑,就是若是想點擊一個正在執行uiview動畫的控件,例如是改變x,y的位置,即便咱們在網上搜到配置的UIViewAnimationOptionAllowUserInteraction也是不行觸發點擊,緣由就是控件首先執行了animations動畫,x,y軸已經改變。
函數
解決辦法一:再覆蓋一個動畫,設置爲alpha爲0.99,由這個控件觸發你的事件動畫
解決辦法二(推薦):使用真正的延遲dispatch_afterui
1 dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 2 [UIView animateWithDuration:0.5 animations:^{ 3 // 移動的動畫 4 } completion:^(BOOL finished) { 5 // 動畫完成的設置 6 }]; 7 });