1

我正在尝试自定义 MultipleSelectorRow 呈现的控制器的背景,但我不能。

  <<< MultipleSelectorRow<String>("select") { row in
    row.options = values
    row.onPresentCallback = { _, to in
     let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: (self.tableView?.bounds.size.width)!, height: (self.tableView?.bounds.size.height)!))
     backgroundView.backgroundColor = UIColor.red
     to.tableView?.backgroundView = backgroundView
    }
  }

这不起作用,因为触发回调时 to.tableView 为零。

我认为如果不对 Eureka 库进行修改,就不可能修改控制器

编辑:添加一些屏幕截图以更好地理解: 尤里卡形式 多重选择器行

谢谢

4

2 回答 2

1

我找到了一个解决方案,我通过以下方式对原始的 MultipleSelectorViewController 进行了子类化:

import Foundation
import Eureka
import ChameleonFramework

public class MFAMultipleSelectorViewController<T:Hashable> : MultipleSelectorViewController<T> {

  open override func viewDidLoad() {
    super.viewDidLoad()
    setTableViewBackgroundGradient(FlatMintDark(), FlatMintDark().lighten(byPercentage: 0.05)!)
  }
  func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    cell.backgroundColor = ClearColor()
  }
}

open class _MFAMultipleSelectorRow<T: Hashable, Cell: CellType>: GenericMultipleSelectorRow<T, Cell, MFAMultipleSelectorViewController<T>> where Cell: BaseCell, Cell: TypedCellType, Cell.Value == Set<T> {
  public required init(tag: String?) {
    super.init(tag: tag)
  }
}

public final class MFAMultipleSelectorRow<T: Hashable> : _MFAMultipleSelectorRow<T, PushSelectorCell<Set<T>>>, RowType {
  public required init(tag: String?) {
    super.init(tag: tag)
  }
}

截屏

于 2016-12-05T16:19:45.857 回答
0

使用默认的单元格定制器

LabelRow.defaultCellUpdate = { cell, row in
    cell.contentView.backgroundColor = .red
    cell.textLabel?.textColor = .white
    cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 13)
    cell.textLabel?.textAlignment = .right
于 2016-12-02T14:32:20.930 回答