2013-05-16 3 views
1
- (IBAction)didTouchAnimate:(UIButton*)sender { 

    UIImage *starImage = [UIImage imageNamed:@"star.png"]; 
    UIImageView *starView = [[UIImageView alloc] initWithImage:starImage]; 
    [starView setCenter:sender.center]; 

    [UIView animateWithDuration:1.50f delay:0.0f options:UIViewAnimationCurveEaseInOutanimations:^{ 
         [starView setCenter:CGPointMake(+100, +100)]; 
         [starView setAlpha:0.6f]; 
        } 
        completion:^(BOOL finished){ 
         [starView removeFromSuperview]; 
         // points++; 
         // NSLog(@"points: %i", points); 
        }]; 

    [self.view addSubview:starView]; 
} 

나는 배열 목록을 가지고 있습니다. 이러한 이미지를 어떻게 애니 메이팅 할 수 있습니까?이미지 배열에 애니메이션을 적용하는 UIImage

Dollars.animationImages = [NSArray arrayWithObjects: 
[UIImage imageNamed:@"score_animate_0001.png"], 
[UIImage imageNamed:@"score_animate_0002.png"], 
[UIImage imageNamed:@"score_animate_0003.png"], 
[UIImage imageNamed:@"score_animate_0004.png"], 
[UIImage imageNamed:@"score_animate_0005.png"], 
[UIImage imageNamed:@"score_animate_0006.png"], 
[UIImage imageNamed:@"score_animate_0007.png"],nil]; 
+0

안녕 친구 (didTouchAnimate) 클릭하면 올바르게 움직일 것이다.하지만 내 문제는 그 때 나는 모든 배열 이미지를 클릭하고 (didTouchAnimate) 애니메이션을 적용하고 싶습니다. 이 문제가 발생하면 도와주세요. – Balaji

답변

1

사용

- (IBAction)didTouchAnimate:(UIButton*)sender { 

    UIImageView *animatingImageView = [[UIImageView alloc] initWithFrame:some.frame]; 
    animatingImageView.animationImages = Dollars.animationImages; 
    animatingImageView.animationDuration = 10; 
    [animatingImageView startAnimating]; 

or simply 
[animatingImageView animatedImagesWithImages:Dollars.animationImages duration:10] 
} 
2

이 튜토리얼은 당신을 도울 것입니다 ... 그밖에

UIImageView animation Tutorial

, 당신의 didTouchAnimate 방법 안에이 작업을 수행

UIImageView * animatedImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200,200)]; 

testArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"test_001.png"], [UIImage imageNamed:@"test_002.png"],[UIImage imageNamed:@"test_001.png"],nil]; 
animTime =3.0; 
[animatedImageView setAnimationImages:testArray] ; 
animatedImageView.animationDuration = animTime; 
animatedImageView.animationRepeatCount = 1; 
[self.view addSubview: animatedImageView]; 
[animatedImageView startAnimating]; 
0

사용

[starView animatedImagesWithImages:Dollars.animationImages duration:10] 
0

스위프트 여기에 3.0 이다 사용자 정의 스타일과 애니메이션

확장 UIImageView에 {

func animate(images: [UIImage], index: Int = 0, duration: TimeInterval, completionHandler: (() -> Void)?) { 

    UIView.transition(with: self, duration: duration/Double(images.count), options: .transitionCrossDissolve, animations: { 
     self.image = images[index] 

    }, completion: { value in 
     let idx = index == images.count-1 ? 0 : index+1 

     if idx == 0 { 
      completionHandler!() 

     } else { 
      self.animate(images: images, index: idx, duration: duration/Double(images.count),completionHandler: completionHandler) 
     } 

    }) 
} 

} 내 문제는 이미지 때 애니메이션을 어떻게

관련 문제