gpt4 book ai didi

ios - MultipleSelectorRow 自定义

转载 作者:行者123 更新时间:2023-11-28 06:29:03 25 4
gpt4 key购买 nike

我正在尝试自定义由 MultipleSelectorRow 呈现的 Controller 背景,但我不能。

  <<< 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 库的情况下修改 Controller 是不可能的

编辑:添加一些屏幕截图以更好地理解: eureka form MultipleSelectorRow

谢谢

最佳答案

我找到了一个解决方案,我按以下方式将原始的 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)
}
}

screenshot

关于ios - MultipleSelectorRow 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40933783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com