ios - 在单元格中创建和调整 UIButton

标签 ios uitableview uibutton

我想在表的最后一行下面创建一个按钮(不是动态的)。所有的行和部分都是固定的。我是否必须创建另一个部分和行来添加一个按钮?如果是,我怎样才能将按钮调整到与单元格相同的宽度和曲率?

这是我做的。我为按钮创建了一个特定部分并为其创建了一行。

}else if(indexPath.section ==2)
    {
        UIButton *cellButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [cellButton setFrame:CGRectMake(0.0f, 5.0f, cell.frame.size.width, 44.0f)]; // not filling the round parts of the cell
        [cellButton setBackgroundColor: [UIColor yellowColor]];
        [cellButton setTitle:@"test" forState:UIControlStateNormal];
        [cell.contentView addSubview:cellButton];
    }

    return cell;

最佳答案

你不知道。将您的按钮设置为表格 View 的表格页脚 View 。

tableView.tableFooterView = myButton;

关于ios - 在单元格中创建和调整 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11733699/

相关文章:

ios - Swift:在文档目录中创建 csv 文件

objective-c - 在 Objective C 方法中创建 UIButton

ios - 使用不同对象时未执行 UIButton 目标操作

ios - 如何在按下 UIButton 按钮时关闭按钮阴影?

ios - 在 RubyMotion 应用程序中使用 Facebook SDK

ios - 在更多菜单中更改 UITabBar 色调颜色

iOS 15 在进入 BLE 信标区域时不会唤醒应用程序

swift - xcode 7 swift 如何使容器 View 透明

ios - 在自定义 UITableViewCell 中单击按钮时重新加载 UITableView

ios - 如何在 UITableViewCell 内实现动态大小的 UICollectionView?