我正在尝试使用此代码调整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];}
最佳答案
使用此代码...
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
CGRect f = deleteButtonView.frame;
f.origin.x = 250;
f.origin.y = 47;
f.size.width = 30;
f.size.height = 50;
CGRect sf = self.frame;
sf.size.width = 100;
sf.size.height = 100;
deleteButtonView.frame = f;
self.frame = sf;
}
从此链接中看到另一个答案... iphone-uitableview-delete-button
关于iphone - UITableviewCell的删除按钮的自定义大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16228932/