1
我很开心,需要帮助。 我与故事板一起工作,并希望在淡出的照片展示中自动淡入淡出。 问题是我有10个图像,现在不要如何编程。 我希望有人能帮助我。自动淡入淡出多张图片
我很开心,需要帮助。 我与故事板一起工作,并希望在淡出的照片展示中自动淡入淡出。 问题是我有10个图像,现在不要如何编程。 我希望有人能帮助我。自动淡入淡出多张图片
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){
//
}];
}
感谢您的快速帮助。我只有一个问题,当他为动画制作动画 –
时,图像不同步10个图像设置animationduration为7.5 ..因为时间间隔为.75持续时间 – AppleDelegate
和animateWithDuration?在 - (void)交叉淡入淡出? –