代码库> 特效> QuickBarTips
QuickBarTips
关注
上传者:libing1125 分类:特效(Specially Effect)
查看次数:1683 下载次数:189
上传时间:2015-09-26 大小:31 B


+(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;
        }];
        
    }
}




收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0
提示
sina weixin mail 回到顶部