ios 添加朦层

时间:2022-06-01 18:02:23
@interface RootViewController : UIViewController
{
UIView *view;
}
-(void)createBackgroundView
{
view = [[UIView alloc]initWithFrame:self.view.frame];
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0];
view.opaque = NO;

UIWindow *appWindow = [[UIApplicationsharedApplication] keyWindow];


[appWindow addSubview:view]; //覆盖全屏

    [self.view addSubview:view];
[UIView animateWithDuration:0.2 animations:^{
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.25];
}];
}