// MARK: 1.10、退出app(类似点击home键盘)退到后台
    /// 退出app(类似点击home键盘)
    public static func exitApp() {
        DispatchQueue.main.async {
            UIApplication.shared.perform(#selector(NSXPCConnection.suspend))
        }
    }

 

2.类似闪退

            guard let window = UIApplication.shared.keyWindow else { return }
            UIView.animate(withDuration: 0.5, animations: {
                window.alpha = 0
                window.frame = CGRect(x: 0, y: window.bounds.size.height / 2, width: window.bounds.size.width, height: 0.5)
            }) { _ in
                exit(0)
            }

 

- (void)exitApplication {
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [UIView animateWithDuration:0.5f animations:^{
        window.alpha = 0;
        window.frame = CGRectMake(0, window.bounds.size.height / 2, window.bounds.size.width, 0.5);
    } completion:^(BOOL finished) {
        exit(0);
    }];
}

 

 

3.

    /// APP主动崩溃
    static func exitApp() {
        // 默认的程序结束函数
        abort()
    }

 

posted on 2025-04-08 08:26  懂事长qingzZ  阅读(33)  评论(0)    收藏  举报