12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // SPSBPopupViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/4/26.
- //
- #import "SPSBPopupViewController.h"
- @interface SPSBPopupViewController ()
- @end
- @implementation SPSBPopupViewController
- - (instancetype)init {
- self = [super init];
- if (!self) return nil;
- self.modalPresentationStyle = UIModalPresentationCustom;
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupAnimation];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (!self.isBeingPresented) {
- [self.presentingViewController viewWillAppear:animated];
- }
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if (!self.isBeingPresented) {
- [self.presentingViewController viewDidAppear:animated];
- } else {
- [self.view setNeedsLayout];
- [self.view layoutIfNeeded];
- [self showAnimation];
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- if (!self.isBeingDismissed) {
- [self.presentingViewController viewWillDisappear:animated];
- }
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- if (!self.isBeingDismissed) {
- [self.presentingViewController viewDidDisappear:animated];
- }
- }
- - (UIStatusBarStyle)preferredStatusBarStyle {
- UIViewController *vc = self.presentingViewController;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- return ((UIViewController *)((UINavigationController *)self.presentingViewController).viewControllers.lastObject).preferredStatusBarStyle;
- } else {
- return vc.preferredStatusBarStyle;
- }
- return self.presentingViewController.preferredStatusBarStyle;
- }
- - (void)setupAnimation {
- self.view.alpha = 0;
- }
- - (void)hideAnimation:(void(^_Nullable)(BOOL))completion {
- [UIView animateWithDuration:0.3 animations:^{
- self.view.alpha = 0;
- } completion:completion];
-
- }
- - (void)showAnimation {
- [UIView animateWithDuration:0.3 animations:^{
- self.view.alpha = 1;
- }];
- }
- @end
|