【发布时间】:2013-04-26 04:45:30
【问题描述】:
我正在尝试使用此代码调整UITableView 单元格的删除按钮的大小,但由于某种原因,x 和 y 工作正常,但我无法更改删除按钮的高度和宽度。我在我的自定义 UITableViewCell 类中使用此代码,一切正常,超出“删除”按钮的宽度和高度。
我在这里错过了什么?
- (void)layoutSubviews
{
[super layoutSubviews];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.0f];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
CGRect newFrame = subview.frame;
newFrame.origin.x = 250;
newFrame.origin.y = 47;
newFrame.size.height = 30;
newFrame.size.width = 50;
deleteButtonView.frame = newFrame;
subview.frame = newFrame;
}
}
[UIView commitAnimations];}
【问题讨论】:
-
使用约束并避免任何 UI 故障的解决方案:stackoverflow.com/a/36159390/882754
标签: iphone ios objective-c uitableview