Reputation: 13073
Does one of the following functions has an advanced over the other, or does it not matter in performance/best practice?
1.
UIView.animate(withDuration: 1){
for b in self.someArray{
b.frame.origin = self.myNewPosition
}
}
2.
for b in self.someArray{
UIView.animate(withDuration: 1){
b.frame.origin = self.myNewPosition
}
}
Upvotes: 2
Views: 148
Reputation: 318884
Option 1 creates a single animation and all of the updated properties are animated together.
Option 2 creates X number of animations and each one can do whatever you want.
Use option 1 if you want all of the origins to change at the same time for the same duration.
Use option 2 if you want a different animation for each object in the array.
Upvotes: 3