日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

animateWithDuration:animations:completion:

發布時間:2025/4/16 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 animateWithDuration:animations:completion: 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么80%的碼農都做不了架構師?>>> ??

Creates an animation block object that can be used to set up keyframe-based animations for the current view.

Declaration

  • (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Parameters

  • duration

The duration of the overall animation, measured in seconds. If you specify a negative value or 0, changes are made immediately and without animations.

  • delay

Specifies the time (in seconds) to wait before starting the animation.

  • options

A mask of options indicating how you want to perform the animations. For a list of valid constants, see “UIViewKeyframeAnimationOptions”.

  • animations

A block object containing the changes to commit to the views. Typically, you call the addKeyframeWithRelativeStartTime:relativeDuration:animations: method one or more times from inside this block. You may also change view values directly if you want those changes to animate over the full duration. This block takes no parameters and has no return value. Do not use a nil value for this parameter.

  • completion

A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. You can use a nil value for this parameter.

我一直不明白最后的completion什么用,參考中的回答者大概回答了。

意思是說你可以當你中斷或者取消了一個動畫,里面的completion會為FALSE。你要清楚,雖然取消了這個動畫,但是completion block回調函數仍然會執行。如果你連接了動畫序列,你想讓這個序列停止的話,你只需要繼續之前已經完成的動畫。

如果你寫一個游戲,預期是炸彈從屏幕飛過。那么你有一個動畫來讓炸彈移動,你的completion block寫的是另外一個動畫來展示炸彈爆炸,然后下面你可能調用一些方法來減分或者其他。

如果玩家點擊了炸彈,你應該取消炸彈的移動動畫,然后炸彈安然無恙的飛過。你之前的completion仍然會執行,所以你應該知道動畫已經被執行結束或者被取消。

參考:http://stackoverflow.com/questions/8686922/what-exactly-does-bool-parameter-do-in-animatewithdurationanimationscompletion

轉載于:https://my.oschina.net/itfanr/blog/372903

總結

以上是生活随笔為你收集整理的animateWithDuration:animations:completion:的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。