ios之animateWithDuration的坑

來源:互聯網
上載者:User

標籤:mat   time   options   pre   ios   get   事件   位置   val   

[UIView animateWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>

這個函數首先需要animations動畫設定是函數調用立即執行,而延遲的時間是執行completion的。  這裡有一個坑,就是如果想點擊一個正在執行uiview動畫的控制項,例如是改變x,y的位置,即使我們在網上搜到配置的UIViewAnimationOptionAllowUserInteraction也是不行觸發點擊,原因就是控制項首先執行了animations動畫,x,y軸已經改變。


解決辦法一:再覆蓋一個動畫,設定為alpha為0.99,由這個控制項觸發你的事件

解決辦法二(推薦):使用真正的延遲dispatch_after

1 dispatch_after(popTime, dispatch_get_main_queue(), ^(void){2         [UIView animateWithDuration:0.5 animations:^{3             // 移動的動畫4         } completion:^(BOOL finished) {5             // 動畫完成的設定6         }];7     });

 

ios之animateWithDuration的坑

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.