|
36 | 36 | @interface SIAlertView () |
37 | 37 |
|
38 | 38 | @property (nonatomic, strong) NSMutableArray *items; |
39 | | -@property (nonatomic, weak) UIWindow *oldKeyWindow; |
40 | 39 | @property (nonatomic, strong) UIWindow *alertWindow; |
41 | | -@property (nonatomic, assign) UIViewTintAdjustmentMode oldTintAdjustmentMode; |
42 | 40 | @property (nonatomic, assign, getter = isVisible) BOOL visible; |
43 | 41 |
|
44 | 42 | @property (nonatomic, strong) UILabel *titleLabel; |
@@ -288,23 +286,34 @@ + (void)showBackground |
288 | 286 | animations:^{ |
289 | 287 | __si_alert_background_window.alpha = 1; |
290 | 288 | }]; |
| 289 | + |
| 290 | + UIWindow *mainWindow = [UIApplication sharedApplication].windows[0]; |
| 291 | + mainWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed; |
291 | 292 | } |
292 | 293 | } |
293 | 294 |
|
294 | 295 | + (void)hideBackgroundAnimated:(BOOL)animated |
295 | 296 | { |
296 | | - if (!animated) { |
| 297 | + void (^completion)(void) = ^{ |
297 | 298 | [__si_alert_background_window removeFromSuperview]; |
298 | 299 | __si_alert_background_window = nil; |
| 300 | + |
| 301 | + UIWindow *mainWindow = [UIApplication sharedApplication].windows[0]; |
| 302 | + mainWindow.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; |
| 303 | + [mainWindow makeKeyWindow]; |
| 304 | + mainWindow.hidden = NO; |
| 305 | + }; |
| 306 | + |
| 307 | + if (!animated) { |
| 308 | + completion(); |
299 | 309 | return; |
300 | 310 | } |
301 | 311 | [UIView animateWithDuration:0.3 |
302 | 312 | animations:^{ |
303 | 313 | __si_alert_background_window.alpha = 0; |
304 | 314 | } |
305 | 315 | completion:^(BOOL finished) { |
306 | | - [__si_alert_background_window removeFromSuperview]; |
307 | | - __si_alert_background_window = nil; |
| 316 | + completion(); |
308 | 317 | }]; |
309 | 318 | } |
310 | 319 |
|
@@ -454,11 +463,6 @@ - (void)show |
454 | 463 | return; |
455 | 464 | } |
456 | 465 |
|
457 | | - self.oldKeyWindow = [[UIApplication sharedApplication] keyWindow]; |
458 | | - |
459 | | - self.oldTintAdjustmentMode = self.oldKeyWindow.tintAdjustmentMode; |
460 | | - self.oldKeyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed; |
461 | | - |
462 | 466 | if (![[SIAlertView sharedQueue] containsObject:self]) { |
463 | 467 | [[SIAlertView sharedQueue] addObject:self]; |
464 | 468 | } |
@@ -589,14 +593,6 @@ - (void)dismissAnimated:(BOOL)animated cleanup:(BOOL)cleanup |
589 | 593 | [SIAlertView hideBackgroundAnimated:YES]; |
590 | 594 | } |
591 | 595 | } |
592 | | - |
593 | | - UIWindow *window = self.oldKeyWindow; |
594 | | - window.tintAdjustmentMode = self.oldTintAdjustmentMode; |
595 | | - if (!window) { |
596 | | - window = [UIApplication sharedApplication].windows[0]; |
597 | | - } |
598 | | - [window makeKeyWindow]; |
599 | | - window.hidden = NO; |
600 | 596 | } |
601 | 597 |
|
602 | 598 | #pragma mark - Transitions |
|
0 commit comments