如何使用 Eureka 制作多行标签

How to make multiline label with Eureka

我在使用 Eureka library 时遇到了问题。我需要一个多行标签行,但不知道该怎么做。我只能看到带有截断标签行的一行。

 class MainViewController: FormViewController {
    override func viewDidLoad() {
      super.viewDidLoad()

      form +++=

        Section()

        <<< LabelRow { row in
            row.title = "Hello World 1. Hello World 2. Hello World 3"
        }
 }

我不太确定你的 Eureka 库做了什么,但是如果你想为你的标签添加多行,在你的故事板中,只需将 "Lines" 属性 更改为 0。

如果您的标签位于 UITableViewCell 内,您需要设置动态 UITableViewCell 高度。

使用 row.cell 您可以获得整个单元格并且可以自定义它。

标签行应该像这样:

<<< LabelRow { row in
    row.title = "Hello World 1. Hello World 2. Hello World 3"
    row.cell.textLabel?.numberOfLines = 0
}

接受的答案还可以,但要更好。您可以将 defaultCallSetup 用于所有 LabelRow、TextAreaRow 和其他。像下面一样。

LabelRow.defaultCellSetup = {cell, row in
    cell.textLabel?.font = UIFont(name: "Your_Custom_font_Name", size: 13)
    cell.detailTextLabel?.textColor = UIColor.yellow
    cell.textLabel?.numberOfLines = 0
    cell.textLabel?.textAlignment = .justified
    cell.textLabel?.backgroundColor = UIColor.clear
}


+++ LabelRow(){
       [=10=].title = "Question    :   Current Occupancy and long text goes"
    }

所有的textLabel属性都可以这样使用。