我想调整附加在 UITableView
上的 UISwitch
按钮的大小。我在谷歌上找到了一些帮助,并使用 CGAffineTransformMakeScale
成功完成了这项工作,但是当我改变这个开关按钮的位置时,我遇到了一个问题,它变成了它自己的原始大小,可能是因为它在表格 View 上,但我在 ViewDidLoad
委托(delegate)中调整它的大小。这就是我正在做的事情。
- (void)viewDidLoad{
switchFB = [[UISwitch alloc] initWithFrame:CGRectMake(227, 8, 79, 27)];
switchFB.transform= CGAffineTransformMakeScale(0.7, 0.7);}
并在单元格中为索引路径处的行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{`static NSString *CellIdentifier = @"SettingsCell";`
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
请检查我哪里做错了,如果我的程序不正确,那么您能否建议我一些更好的方法来做到这一点。这对我来说很棒。提前致谢。
最佳答案
试试这个
UISwitch *mySwitch = [UISwitch new];
mySwitch.transform = CGAffineTransformMakeScale(0.75, 0.75);
关于iphone - 如何调整 UISwitch 按钮的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15196564/