+(void)show:(NSString *)tips{
[NSObject cancelPreviousPerformRequestsWithTarget:[self shared] selector:@selector(hideTooltip) object:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[[self shared] tooltipCreate];
[self shared].tooltip.text = tips;
[[self shared] tooltipOrient];
[[self shared] layoutSubviews];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
UIInterfaceOrientation orient = [[UIApplication sharedApplication]statusBarOrientation];
if (CURRENTDEVICE >= 8.0) {
if (orient == UIInterfaceOrientationLandscapeLeft) {
animation.fromValue = @-20;
}else if (orient == UIInterfaceOrientationLandscapeRight){
animation.fromValue = @20;
}
}
animation.toValue = @0;
animation.duration = .5f;
[[self shared].container.layer addAnimation:animation forKey:@"translation"];
});
[[self shared] performSelector:@selector(hideTooltip) withObject:nil afterDelay:2];
}
-(void)hideTooltip{
dispatch_async(dispatch_get_main_queue(), ^{
[[QuickTipBar shared] hide];
});
}
-(void)hide{
if (tooltip.superview) {
NSUInteger options = UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn;
[UIView animateKeyframesWithDuration:.5f delay:0 options:options animations:^{
container.transform = CGAffineTransformTranslate(container.transform, 0, - container.frame.size.height);
tooltip.alpha = 0;
} completion:^(BOOL finished) {
[tooltip removeFromSuperview];
tooltip = nil;
for (UIGestureRecognizer *rec in container.gestureRecognizers ) {
[container removeGestureRecognizer:rec];
}
[container removeFromSuperview];
container = nil;
}];
}
}