/******* 假夜间模式 *********/
// 开关
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];
}
}