iOS 夜间模式的简单实现


//夜间模式

@property(nonatomic,strong)UIView * darkView;//全局变量


self.darkView = [[UIView alloc]initWithFrame:self.view.bounds];




    UIApplication * app = [UIApplication sharedApplication];

            AppDelegate * delegate = app.delegate;

            _darkView.backgroundColor = [UIColor blackColor];

            _darkView.alpha =0.5;

            _darkView.userInteractionEnabled = NO;

            [delegate.window addSubview:_darkView];


//改成白天模式

 [_darkView removeFromSuperview];



你可能感兴趣的:(iOS 夜间模式的简单实现)