Closed wutschel closed 2 months ago
@kambala-decapitator, I looked into options and found the following. Does this look reasonable?
typedef void (^animationBlock)(void);
+ (void)AnimView:(UIView*)view AnimDuration:(NSTimeInterval)seconds Alpha:(CGFloat)alphavalue XPos:(int)X YPos:(int)Y {
animationBlock animation = ^{
CGRect frame = view.frame;
frame.origin.x = X;
frame.origin.y = Y;
view.frame = frame;
};
[Utilities animateWithDuration:seconds animation:animation];
}
+ (void)animateWithDuration:(NSTimeInterval)seconds animation:(animationBlock)animation {
if (seconds > 0.0) {
[UIView animateWithDuration:seconds
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:animation
completion:nil];
}
else {
animation();
}
}
Looks like too much unnecessary work to me. Can't you just avoid any animation code for 0.0 cases completely?
In this case I would just create AnimView:Alpha:XPos:
, w/o the duration parameter.
During code review several occasions of animation with 0 seconds durations were found. This can be handled w/o animations at all. Search for
AnimDuration:0.0
.