UISwitch *noticeSwtich = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 51, 31)]; // noticeSwtich.layer.cornerRadius = noticeSwtich.height/2; // noticeSwtich.backgroundColor = RGB(0, 187, 39); // noticeSwtich.tintColor = RGB(0, 187, 39);//设置关着的时候的颜色 noticeSwtich.onTintColor = RGB(0, 187, 39);//设置开着的时候的颜色 [noticeSwtich addTarget:self action:@selector(noticeSwitchAction:) forControlEvents:UIControlEventValueChanged]; cell.accessoryView = noticeSwtich;