MultipleSelectorRow 自定义
MultipleSelectorRow customization
我正在尝试自定义由 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 为 nil。
我认为不修改 Eureka 库就不可能修改控制器
编辑:添加一些屏幕截图以更好地理解:
谢谢
LabelRow.defaultCellUpdate = { cell, row in
cell.contentView.backgroundColor = .red
cell.textLabel?.textColor = .white
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 13)
cell.textLabel?.textAlignment = .right
我找到了一个解决方案,我按以下方式将原始的 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)
}
}
我正在尝试自定义由 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 为 nil。
我认为不修改 Eureka 库就不可能修改控制器
编辑:添加一些屏幕截图以更好地理解:
谢谢
LabelRow.defaultCellUpdate = { cell, row in
cell.contentView.backgroundColor = .red
cell.textLabel?.textColor = .white
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 13)
cell.textLabel?.textAlignment = .right
我找到了一个解决方案,我按以下方式将原始的 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)
}
}