我只是在做一个开关,它会改变 tableview 上的颜色。
我有 MasterViewController,它具有“tableview”颜色、数据等。我还有称为 InfoViewController 的设置控制器,它有开关。
我无法从 InfoViewController 更改颜色值。
InfoViewController 切换代码:
-(IBAction)switch:(id)sender
{
MasterViewController *destViewController = [[MasterViewController alloc] initWithNibName:nil bundle:nil];
static NSString *CellIdentifier = @"ElementCell";
UITableViewCell *cell = [destViewController.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (color == @"Black") {
cell.textLabel.textColor = [UIColor whiteColor];
destViewController.tableView.backgroundColor = [UIColor blackColor];
destViewController.tableView.separatorColor = [UIColor whiteColor];
}else if(color == @"White"){
destViewController.tableView.backgroundColor = [UIColor whiteColor];
destViewController.tableView.separatorColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor blackColor];
}
}
我正在使用故事板。