Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...