// // MoveMegAlert.m // smartRhino // // Created by niuzhen on 2020/4/30. // Copyright © 2020 tederen. All rights reserved. // #import "MoveMegAlert.h" static UINib *ViewNib = nil; @interface MoveMegAlert() @end static MoveMegAlert *alert = nil; static dispatch_once_t onceToken; @implementation MoveMegAlert + (instancetype)share { dispatch_once(&onceToken, ^{ if (ViewNib == nil) { ViewNib = [UINib nibWithNibName:@"MoveMegAlert" bundle:nil]; } alert = [[ViewNib instantiateWithOwner:nil options:nil] lastObject]; [alert setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; alert.backgroundColor = [UIColor clearColor]; // [alert.disBtn addTarget:alert action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; [alert.cancelBtn addTarget:alert action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; [alert.doneBtn addTarget:alert action:@selector(doneAction) forControlEvents:UIControlEventTouchUpInside]; }); return alert; } - (void)doneAction { if (self.DoneBlock) { self.DoneBlock(); } [self dismiss]; } - (void)show { UIWindow *window = [[UIApplication sharedApplication].windows lastObject]; [window addSubview:self]; [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ } completion:^(BOOL finished) { }]; } - (void)dismiss { WS(weakSelf); [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ } completion:^(BOOL finished) { [weakSelf removeFromSuperview]; }]; } @end