iPhone – 如何调整UISwitch按钮的大小?

前端之家收集整理的这篇文章主要介绍了iPhone – 如何调整UISwitch按钮的大小?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想调整我在UITableView上附加的UISwitch按钮的大小.我在google上找到了一些帮助并使用CGAffineTransformMakeScale成功完成了这个但是我得到了一个问题,当我改变位置时这个开关按钮它自己的原始大小可能是因为它在桌面视图但我在ViewDidLoad委托中调整大小.这就是我在做的事情.

- (void)viewDidLoad{
 switchFB = [[UISwitch alloc] initWithFrame:CGRectMake(227,8,79,27)];
switchFB.transform= CGAffineTransformMakeScale(0.7,0.7);}@H_404_12@ 
 

在索引路径的行中的单元格中

- (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;
    }@H_404_12@ 
 

请检查我在哪里做错了,如果我的程序不对,那么请你建议我做一些更好的方法.这对我来说很棒.提前致谢.

解决方法

试试这个

UISwitch *mySwitch = [UISwitch new];
mySwitch.transform = CGAffineTransformMakeScale(0.75,0.75);@H_404_12@

猜你在找的Xcode相关文章