经常遇到一些产品需求,如果不符合什么条件,或者不遵循什么协议,就退出app
上代码
#import "AppDelegate.h"//导入头文件
-(void)exitApplication {
AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate;
//此处如果不强转 AppDelegate,会报警告:Initializing 'AppDelegate *__strong' with
// an expression of incompatible type 'id<UIApplicationDelegate>
UIWindow *window = app.window;
// 动画 1
[UIView animateWithDuration:0.6f animations:^{
window.alpha = 0;
window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
} completion:^(BOOL finished) {
exit(0);
}];
}
搞定!!!