prevent multiple Toast overlaps in ios

This commit is contained in:
Richie 2014-08-14 11:19:16 +08:00
parent e6c1c89f14
commit 654dccb05a

View File

@ -46,6 +46,8 @@ static const BOOL CSToastHidesOnTap = YES; // excludes activity
static const NSString * CSToastTimerKey = @"CSToastTimerKey";
static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey";
static UIView *prevToast = NULL;
@interface UIView (ToastPrivate)
- (void)hideToast:(UIView *)toast;
@ -91,6 +93,10 @@ static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey";
}
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)point {
if(prevToast){
[self hideToast:prevToast];
}
prevToast = toast;
toast.center = [self centerPointForPosition:point withToast:toast];
toast.alpha = 0.0;