开发者

UIImage view animation problem

开发者 https://www.devze.com 2023-02-06 21:51 出处:网络
I have done the effect of playing lots of images like below: NSInteger faceNum = 12; NSMutableArray *faceArray = [[NSMutableArray alloc] initWithCapacity:faceNum];

I have done the effect of playing lots of images like below:

NSInteger faceNum = 12;

NSMutableArray *faceArray = [[NSMutableArray alloc] initWithCapacity:faceNum];

for (int i = 1;i<faceNum+1; i++) {
    NSString *facename = [[NSBundle mainBundle] 
      pathForResource:[NSString   stringWithFormat:@"animationFace%d",i] ofType:@"png"];    
    UIImage *faceImage = [UIImage imageWithContentsOfFile:facename];    
    [faceArray addObject:faceImage];
}

 UIImageView *faceView = [[UIImageView alloc] 
   initWithFrame:CGRectMake(414, 157, 161, 124)];

 faceView.animationImages = faceArray;    
 faceView.animationDuration = 30;    
 faceView.animationRepeatCount = 0;

 [faceView startAnimating];    
 [self.view addSubview:faceView];    
 开发者_JS百科[faceView release];    
 [faceArray release];

And how to add the EaseInEaseOut effect to this.One picture disappear gradually,then another picture appear gradually. Thanks


There is no inbuilt fade-in and out feature with imageview startAnimating. You can achieve this by manually setting the alpha of two view laid over each other:

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.5f];

    imageviewToFadeOut.alpha = 0.0f;
    imageviewToFadeIn.alpha = 1.0f;

    [UIView commitAnimations];

and setImage manually alternatively to these UIViews.

[imageview setImage:image];

and to recursively call this method, use something like [self performSelector:@selector(methodname) withObject: afterDelay: ] inside the method itself.

Edit: For clarity, specifying the recursion to call this method over and over with delay:

-(void)methodname {

.. (do your task)
[self performSelector:@selector(methodname) withObject:NULL afterDelay:10 ];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消