使Eureka DateTimeInlineRow值显示在textLabel而不是detailTextLabel中

时间:2017-11-30 18:28:43

标签: ios swift eureka-forms

因此,我尝试自定义Eureka库中的DateTimeInlineRow,以在标题位置显示所选日期,而不是详细位置。要替换'占位符' "日期"如下图所示: enter image description here

我尝试了很多方法但没有成功,这是我的最后一次尝试:

        <<< DateTimeInlineRow() { row in
            row.tag = "date"
            }.cellSetup { cell, row in
                row.title = "Date"
            }.cellUpdate { cell , row in
                if let date = row.value {
                    row.title = DateFormatter().string(from: date)
                }
                cell.textLabel?.textColor = row.title == "Date" ? .gray : .black
            }

1 个答案:

答案 0 :(得分:1)

您需要设置cell.textLabel?.text以使日期字符串成为标题

    <<< DateTimeInlineRow() { row in
        row.tag = "date"
        }.cellSetup { cell, row in
            row.title = "Date"
            cell.detailTextLabel?.text = ""
        }.cellUpdate { cell , row in
            if let date = row.value {
                cell.textLabel?.text = row.dateFormatter?.string(from: date)
            }
            cell.textLabel?.textColor = row.title == "Date" ? .gray : .black
            cell.detailTextLabel?.text = ""
    }

<强>截图

enter image description here