簡體   English   中英

Swift Eureka:向ButtonRow添加文本值

[英]Swift Eureka: Adding text value to ButtonRow

目前,我通過在單元格中添加標簽視圖來使用ButtonRow獲得此結果:

在此處輸入圖片說明

<<< ButtonRow("Email") {
            $0.title = $0.tag
            $0.presentationMode = PresentationMode.Show(...)
            }.cellSetup {
                cell, row in

                let text = UILabel(frame: cell.frame)
                text.frame.size.width = 0.909 * currentScreenWidth - 68
                text.frame.origin.x = 68
                text.textColor = UIColor(red: 142/255, green: 142/255, blue: 147/255, alpha: 1)
                text.textAlignment = .Right
                text.text = "fakeEmail@email.com"
                cell.addSubview(text)
 }

我正在使用ButtonRow,因為它的末尾只有“>”,並且在以編程方式呈現新視圖和視圖控制器時,它的效果很好。

使用$0.value = "Some String"不起作用,就像使用其他屬性一樣。

無論如何,無需手動添加標簽視圖即可執行此操作? 它適用於所有屏幕,但是我認為手動設置這些參數並不十分安全。

初始化單元格對象時,ButtonRow的實現使用UITableViewCellStyle'default'。 您可以創建ButtonRow的子類:

public final class DetailedButtonRowOf<T: Equatable> : _ButtonRowOf<T>, RowType {
    public required init(tag: String?) {
        super.init(tag: tag)
        cellStyle = .value1
    }
}
public typealias DetailedButtonRow = DetailedButtonRowOf<String>

然后,您可以指定該行的detailLabelText:

<<< DetailedButtonRow("Email") { row in
    row.title = row.tag
    row.presentationMode = .segueName(segueName: "AStoryboardSegue", onDismiss: nil)
}.cellUpdate({ (cell, row) in
    cell.detailTextLabel?.text = "fakeEmail@email.com"
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM