因此,我尝试自定义Eureka库中的DateTimeInlineRow
,以在标题位置而不是详细信息位置显示所选日期。替换下图中所示的“占位符”“日期”:
我尝试了很多方法都没有成功,这是我最后的尝试:
<<< 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 = ""
}
屏幕截图
关于ios - 使Eureka DateTimeInlineRow值显示在textLabel中,而不是detailTextLabel中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47580288/