簡體   English   中英

延遲動畫UIImageView

[英]Animating a UIImageView with delay

我正在以這種方式對UIImageView進行動畫處理:

int timerAnimation = 0.0f;

for (UIImageView* img in imageArray) {

timerAnimation = timerAnimation + 1.0f;

[UIView animateWithDuration:1.0f
                      delay:timerAnimation
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     img.frame = CGRectMake(20, img.frame.origin.y, 710, 60);
                 }
                 completion:NULL];

我想減少延遲時間,但是我注意到,如果我將值設置為1.0以下,

例如

timerAnimation + 0.5f;

然后所有對象在保存時間移動,好像沒有延遲。 為什么是這樣?

您正在使用int!

int timerAnimation = 0.0f;

應該是浮點數:

CGFloat timerAnimation = 0.0f;

一個int不支持小數,因此您只能在其上加上整數(1.0),而不能加上半數(0.5)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM