我正在尝试创建校准视图!我有 12 个校准点作为 UIImageViews。现在我想显示每个点 5 秒。所以整个校准时间是1分钟。ImageViews 的 Alpha 设置为 0.0!在 UI 动画中,我想一个接一个地将 Alpha 设置为 1.0,每个点仅持续 5 秒。
到目前为止,我做到了(见代码)!但这会让我(淡入)在 5 秒后 5 秒一次全部 12 个点!我如何使用 NSTimer 和 UI 动画一个接一个地解决这个问题?谢谢
-(id)init{
_calibrationViewArray = [[NSMutableArray alloc]init];
_calibrationPoint1 = [[UIImageView alloc]initWithFrame:(CGRectMake(115.5,113.0,25.0,25.0))];
_calibrationPoint1.backgroundColor = [UIColor redColor];
_calibrationPoint1.alpha = 0.0;
[self addSubview:_calibrationPoint1];
[_calibrationViewArray addObject:_calibrationPoint1];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
-(void)onTimer{
for (int i = 0; i < [_calibrationViewArray count]; i++) {
UIImageView* currentCalibrationPoint = [_calibrationViewArray objectAtIndex:i];
[UIView beginAnimations:@"Calibration" context:nil];
[UIView setAnimationDuration:5.0];
// Make the animatable changes.
currentCalibrationPoint.alpha = 1.0;
// Commit the changes and perform the animation.
[UIView commitAnimations];
}
}