// MARK: 1.10、退出app(類似點(diǎn)擊home鍵盤)退到后臺 /// 退出app(類似點(diǎn)擊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() { // 默認(rèn)的程序結(jié)束函數(shù) abort() }
浙公網(wǎng)安備 33010602011771號