Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

cocoa touch - IOS - multiple images going slowly upward animation

i am new to IOS programming. what i want is i want to show multiple images and then they go upward continuously and then repeat again and again in sort of a loop. how can i do this ?

i have total 8 images which i want to show like this

enter image description here

i don't know how can i add 8 images and then they go upward direction verically continuously repeating. please help me in this. if there is any tutorial related to that and then please share

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should not do it this way. If you make your step value small enough for smooth movement it will be too slow.

You want to use UIView animation. Take a look at the the method animateWithDuration:animations: (and it's variations)

Your code might look like this:

#define K_AMOUNT_TO_MOVE

-(void)moveImages
{
  [UIView animateWithDuration: 2.0
    animations: ^
    {
    for(int i=0;i<images.count;i++)
      {
        UIImageView *MyImage = images[i];
        MyImage.center = CGPointMake (MyImage.center.x, MyImage.center.y- K_AMOUNT_TO_MOVE);
      }
    }
  ];
}

There are variations on that basic method that take options that will auto-reverse the animation, make it repeat, change the timing to linear instead of the default ease-in, ease-out, etc. Take a look at the method animateWithDuration:delay:options:animations:completion: in the Xcode documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...