我有一个水平表格视图,想每 5 秒更改一次图像。我想用淡入淡出动画改变图像,使旧图像淡出,新图像淡入。所以我称之为这个方法:
self.slideTimer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(slideToNextImage)
userInfo:nil
repeats:YES];
这是我的slideToNextImage:
self.lastIndexPath = indexPath;
[UIView beginAnimations:@"FadeAnimations" context:nil];
[UIView setAnimationDuration:2];
self.horizontalView.alpha = 0.1f;
[self.horizontalView.tableView scrollToRowAtIndexPath:self.lastIndexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:NO];
[UIView commitAnimations];
[UIView beginAnimations:@"FadeAnimations" context:nil];
[UIView setAnimationDuration:2];
self.horizontalView.alpha = 1.0f;
[UIView commitAnimations];
当我意识到图像褪色太快时,我看到第二张图像滚动时没有褪色动画