APP开启灰色模式
推荐做法:
仅适用于iOS13以上版本
1.创建一个继承UIView的view,然后关闭该View的点击事件
2.添加 self.layer.compositingFilter = @"saturationBlendMode";
3.在需求灰色的页面添加此视图,
整个APP都需要,可以加到window上;
只是单个vc,比如首页,加到vc对应的self.view上即可
整个导航栏栈都需要,可以加到nav.view上
- (instancetype)init
{
self = [super init];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
if (@available(iOS 13.0, *)) {
self.userInteractionEnabled = NO;
self.translatesAutoresizingMaskIntoConstraints = NO;
self.backgroundColor = ULColorLightGray;
self.layer.compositingFilter = @"saturationBlendMode";
} else {
self.backgroundColor = ULColorClear;
}
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
return nil;
}