1

我在这里,需要帮助。我使用故事板并希望制作一个自动淡入淡出的照片秀。问题是我有 10 张图像,现在不知道如何以编程方式制作它。我希望有人能帮助我。

4

1 回答 1

3
  mainImageView = [[UIImageView alloc]init];
    NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"third.png"],[UIImage imageNamed:@"fourth.png"],[UIImage imageNamed:@"fifth.png"],[UIImage imageNamed:@"sixth.png"],[UIImage imageNamed:@"seventh.png"],[UIImage imageNamed:@"eight.png"],[UIImage imageNamed:@"nine.png"],[UIImage imageNamed:@"ten.png"], nil]; //add your images here
                               [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(crossfade) userInfo:nil repeats:YES];
    [mainImageView  setFrame:CGRectMake(50,50,100,100)];
                               mainImageView.animationImages = animationArray; //mainImageView is   imageview
                               mainImageView.animationDuration = 10;
                               mainImageView.animationRepeatCount = 0;
                               [mainImageView startAnimating];


     [self.view addSubview:mainImageView];


    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)crossfade {
    [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
                                       mainImageView.alpha = !mainImageView.alpha;
                                   }completion:^(BOOL done){
                                    //
                }];
}
于 2012-10-11T12:04:21.460 回答