iPhone – 如何调整UISwitch按钮的大小?
发布时间:2020-12-14 17:12:07 所属栏目:百科 来源:网络整理
导读:我想调整我在UITableView上附加的UISwitch按钮的大小.我在google上找到了一些帮助并使用CGAffineTransformMakeScale成功完成了这个但是我得到了一个问题,当我改变位置时这个开关按钮它自己的原始大小可能是因为它在桌面视图但我在ViewDidLoad委托中调整大小.
我想调整我在UITableView上附加的UISwitch按钮的大小.我在google上找到了一些帮助并使用CGAffineTransformMakeScale成功完成了这个但是我得到了一个问题,当我改变位置时这个开关按钮它自己的原始大小可能是因为它在桌面视图但我在ViewDidLoad委托中调整大小.这就是我在做的事情.
- (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); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |