Hello @andreamazz,
I was thinking it could be great to let the user have a choice for the appearance animation, maybe via a UI_APPEARANCE_SELECTOR
enum property like:
typedef NS_ENUM(NSInteger, AMPopTipAppearanceAnimation) {
AMPopTipAppearanceAnimationScaleUp, // scale 2.0 to 1.0
AMPopTipAppearanceAnimationScaleDown, // scale 0.3 to 1.0
AMPopTipAppearanceAnimationFadeIn, // alpha 0 to 1
AMPopTipAppearanceAnimationFadeInTranslate, // alpha 0 to 1 and shift from an offset to final position (translation is depending on popover direction)
AMPopTipAppearanceAnimationNone // no animation at all
};
@property (nonatomic, assign) AMPopTipAppearanceAnimation defaultAppearanceAnimation UI_APPEARANCE_SELECTOR;
What do you think of that?
It could also provide a custom animation block for each AMPopTip
instance:
@property (nonatomic, copy) void (^appearanceAnimationSetup)(void);
@property (nonatomic, copy) void (^appearanceAnimation)(void);
where a user could do something like:
popTip. appearanceAnimationSetup = ^ {
popTip.alpha = 0;
};
popTip. appearanceAnimation = ^ {
popTip.alpha = 1;
};
Or, we can let the user control entirely the animation by doing instead:
@property (nonatomic, copy) void (^appearanceAnimation)(void (^completion)(void));
And implementing it like:
popTip. appearanceAnimation = ^(void (^completion)(void)) {
popTip.alpha = 0;
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:1.5 options:(UIViewAnimationOptionCurveEaseInOut) animations:^{
popTip.alpha = 1;
} completion:completion];
}
Where he has to call back the completion so in AMPopTip
code, it knows when to do after animation code.
The second idea for custom animation might be a little bit too permissive because it makes animationIn
and delayIn
obsolete. Also, for the custom animation, we should provide same properties but for hiding the popover.