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

标签 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
            }

最佳答案

您需要设置 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

关于ios - 使 Eureka DateTimeInlineRow 值显示在 textLabel 而不是 detailTextLabel 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47580288/

相关文章:

ios - 如何将制服传递给着色器

ios - 使用 Core Graphics 从外部存储加载图像无法正常工作 iOS 13

ios - 在 AVCaptureVideoPreviewLayer 中使用 AVFoundation 旋转 90º 进行实时捕获

ios - 加快游戏中所有 Sprite 的速度

swift - Eureka 图像行不会保存到对象

swift - Swift 中的 Eureka 库 : How can I loop rows?

ios - 如何以编程方式向 Eureka 中的表单添加顶部导航?

ios - WKWebView 在 StoryBoard 中还是以编程方式(Swift 4)?

swift - 带有 groupPagingCentered 的 UICollectionViewCompositionalLayout 没有开始居中

swift - 如何设置 Swift 2.0 路径?