APP强制退出

第一种方法:

企业版可以用,Appstore可能被拒,慎用

 1 - (void)exitApplication {
 2     
 3     AppDelegate *app = [UIApplication sharedApplication].delegate;
 4     UIWindow *window = app.window;
 5     window.backgroundColor = [UIColor redColor];
 6 
 7     
 8     [UIView animateWithDuration:1.0f animations:^{
 9         window.alpha = 0;
10         window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
11     } completion:^(BOOL finished) {
12         exit(0);
13     }];
14     
15 }

第二种方法 - 推荐,官方例子经常出现

1       [self performSelector:@selector(sayByeBye)];
2      
3 
4 -(void)sayByeBye{
5     abort();
6 }

 第二种方法用模拟器测试不出来。只能真机。把第一个的exit 替换 abort也有动画效果;

让明天,不后悔今天的所作所为
原文地址:https://www.cnblogs.com/-yun/p/5200135.html