I have a group of UIImageViews that are stored in an array. I want to animate a certain amount of these ImageViews in the same way. Thus, I have been trying to use the following code:
var lowerViews: [UIImageView] = [imageView1, imageView2, imageView3, imageView4]
var startingIndex = 1;
UIView.animateWithDuration(0.3, delay: 0.1, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
for index in startingIndex..< lowerViews.count {
lowerViews[index].frame.origin.y += 100
}
}, completion: nil)
However at this line:
for index in startingIndex..< lowerViews.count {
Xcode gives me the error:
Expected '{' to start the body of each for-loop
However, I don't believe that this is really the issue. This seems to me that it is an arbitrary syntax error that Xcode gets because I am using the for-loop inside the 'animation' parameter. Since I am still learning a lot about Swift I do not know why this wouldn't work, and so if this assumption is correct, I would like to know why and how I can get around this.
If this is not the case, please let me know, because either way I need to get around the problem.
Thanks in advance