swift - 如何在表单的标题中创建自定义 View

标签 swift eureka-forms

我想知道是否可以创建如下图所示的内容。

enter image description here

我想我必须创建一个自定义 View ,但有关于如何创建的线索吗?

谢谢

最佳答案

如果屏幕上有 UITableView,可以通过创建自定义表头 View 来实现:

  1. 创建 UIView 的子类 -> CustomTableHeaderView
  2. 在其中添加一个按钮:

    class CustomTableHeaderView: UIView {
        var rightButton: UIButton
        override init(frame: CGRect) {
            rightButton = UIButton()
            let buttonWidth: CGFloat = 100
            // this is hardcoded for cimplicity, it's better to setup auto layout constraints here
            rightButton.frame = CGRect(x: 0, y: frame.width - buttonWidth, width: buttonWidth, height: 50)
            rightButton.setTitle("My button", forState: .Normal)
            // other configuration
    
            super.init(frame: frame)
        }
    
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        } 
    

    1. 在您的 View Controller 中(或您初始化 TableView 的任何其他地方,将您的自定义 View 设置为 tableHeaderView:

    tableView.tableHeaderView = CustomTableHeaderView(frame: frame:CGRect(x: 0, y: 0, width: view.frame.width, height: 10))

关于swift - 如何在表单的标题中创建自定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38333252/

相关文章:

ios - 更新 RecyclerView 适配器中 Cardview 内的图表

ios - 遍历数组,使用网络调用/回调函数检查每个元素,如果没有找到所需元素,则转到默认值

ios - UITableViewController selectionStyle 无不工作

ios - Apple 的照片应用程序中的过滤器 UIScrollView/UICollectionView 是如何实现的,以至于它打开得如此之快?

swift - Eureka rangeSliderRow

ios - 我想使用非消耗品和自动更新那么,是否可以在一个应用程序中使用 2 个 IAP 产品?

Swift - 使用 Eureka 获取 textField 表单的值

swift - Eureka : Ambiguous reference to member '+++'

ios - Eureka Forms 为选项动态添加值

ios - Eureka 表单中的必填字段