模拟退出软件

1、iOS无法代码关闭软件,只能模拟出用户按Home键,将软件退出的效果:

- (void)exitApplication
{
    AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UIWindow *window = appdelegate.window;
    
    [UIView animateWithDuration:1.0f animations:^{
        
        window.alpha = 0;
        window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
        
    } completion:^(BOOL finished) {
        exit(0);
    }];
}

 

posted @ 2018-04-03 23:57  码出境界  阅读(199)  评论(0编辑  收藏  举报