公司为了提高项目的安全性,需要对目前的项目做一些安全性处理,这么毛玻璃效果就是其中之一.这里做一下代码的记录,方便我以后查阅,也欢迎大家提出修改意见!!(崇拜星爷的程序员);
简书代码咋显示颜色啊,欢迎评论区指导下!!!
先来张星爷:
代码如下:
#import "AppDelegate.h"
@interface AppDelegate ()
@property (nonatomic, strong, nullable) UIVisualEffectView *visualEffectView;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.visualEffectView.alpha = 0;
self.visualEffectView.frame = self.window.frame;
[self.window addSubview:self.visualEffectView];
[UIView animateWithDuration:0.5 animations:^{
self.visualEffectView.alpha = 1;
}];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[UIView animateWithDuration:0.5 animations:^{
self.visualEffectView.alpha = 0;
} completion:^(BOOL finished) {
[self.visualEffectView removeFromSuperview];
}];
}
@end