问题
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
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
回答1:
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.
来源:https://stackoverflow.com/questions/22815506/ios-multiple-images-going-slowly-upward-animation