iOS-UI - 假夜间模式-VC 屏幕遮住

/******* 假夜间模式 *********/

屏幕遮住

// 开关
UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
[sw addTarget:self action:@selector(swAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:sw];
[sw release];

屏幕快照 2016-01-18 下午7.21.31.png

  • (void)swAction:(UISwitch *)sender
    {
    if (YES == sender.on) {
    // 假夜间模式
    self.nightV = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.nightV.backgroundColor = [UIColor blackColor];
    self.nightV.alpha = 0.6;
    self.nightV.userInteractionEnabled = NO;
    [self.view addSubview:self.nightV];
    [self.nightV release];

    } else {
    // 关闭夜间模式 移除视图

      [self.nightV removeFromSuperview];
    

    }
    }

屏幕快照 2016-01-18 下午7.21.44.png

标签: none

添加新评论

Title - Artist
0:00