App在进入后台后,需要使用毛玻璃效果遮盖
@property (nonatomic, strong) UIVisualEffectView *visualView;
- (void)applicationWillResignActive:(UIApplication *)application {
if (!self.visualView) {
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
self.visualView = [[UIVisualEffectView alloc] initWithEffect:blur];
self.visualView.alpha = 0;
self.visualView.frame = self.window.frame;
[self.window addSubview:self.visualView];
}
// 页面转场会出现bug,简单修复下
[self.window bringSubviewToFront:self.visualView];
[UIView animateWithDuration:0.5 animations:^{
self.visualView.alpha = 1;
}];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (self.visualView) {
[UIView animateWithDuration:0.5 animations:^{
self.visualView.alpha = 0;
}];
}
}
网友评论