0

如何在ios app中实现图片下滑动画?

我用过这段代码:

    imageview.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"img10.png"],
                                 [UIImage imageNamed:@"img11.png"],[UIImage imageNamed:@"img12.png"],[UIImage imageNamed:@"img13.png"],nil];
    imageview.animationDuration = 10.00;  

    imageview.animationRepeatCount = 0; 

    [imageview startAnimating];

但这只是一个简单的幻灯片放映。帮我。

4

3 回答 3

0

试试这个代码..

      imageview = [[UIImageView alloc] initWithFrame:self.view.frame];
      imageview.animationImages = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"img10.png"],
                             [UIImage imageNamed:@"img11.png"],[UIImage imageNamed:@"img12.png"],[UIImage imageNamed:@"img13.png"],nil];

        imageview.animationDuration = 1.25;
        imageview.animationRepeatCount = 10;
        [imageview startAnimating];
        [self.view addSubview:animationView];
        [imageview release]; 
于 2012-11-23T11:13:10.613 回答
0

请尝试以下代码

   -(void) createNewImage {
        imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,460)];

        imageView.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"img10.png"],
                                 [UIImage imageNamed:@"img11.png"],
                                 [UIImage imageNamed:@"img12.png"],
                                 [UIImage imageNamed:@"img13.png"],nil];
        [imageView setAnimationRepeatCount:10];
        imageView.animationDuration =1.5;
        [imageView startAnimating]; 
        [NSTimer scheduledTimerWithTimeInterval:15.0 target:self selector:@selector(setLastImage:) userInfo:nil repeats:NO];

     }

    -(void)setLastImage:(id)obj
    {
        [imageView performSelectorOnMainThread:@selector(setImage:) withObject:[UIImage imageNamed:@"img12.png"] waitUntilDone:YES];
    }
于 2012-11-23T11:14:04.400 回答
0

您可以UIImageView使用 imgVw.centre 更改中心,您可以使用NSTimer. 根据屏幕改变中心,您可以获得屏幕高度
[[UIScreen mainScreen]bounds].size.height

theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f 
        target:self 
        selector:@selector(updateTimer:) 
        userInfo:nil 
        repeats:YES];

- (void)updateTimer:(NSTimer *)theTimer {
    //update centre; 
    imgVw.centre.y += 4;
// you can update the image also if needed use if case
imgVw.image = image2;

}
于 2012-11-23T11:27:49.387 回答