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

2016-01-18 19:22:00
/******* 假夜间模式 *********/


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

  • (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];

    }
    }

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »