尤里卡 rangeSliderRow
Eureka rangeSliderRow
有什么方法可以用 eureka 创建范围滑块吗?
像这样。
<<< RangeSlideRow() {
[=10=].maxValue = 10000
[=10=].minValue = 0
[=10=].selectedMaxValue = 9000
[=10=].selectedMinValue = 5
}
eureka中没有range slider,因为UISlider不支持。您将必须基于一些现有的 rangeslider 实现创建您自己的 RangeSlideRow。
查看Eureka中的SliderRow实现以供参考。
我知道我来晚了,但也许下次 this will be useful。
如果您认为对任何人都有帮助,我鼓励您在 Eureka Community 中分享您的行:) 谢谢!
这是我的做法
首次安装TTRangeSlider
然后创建了 RangeViewCell.xib 带有出口
的文件
然后创建文件RangeViewCell.swift
已连接的网点
import Foundation
import UIKit
import Eureka
import TTRangeSlider
public class RangeViewCell: Cell<String>, CellType, TTRangeSliderDelegate {
@IBOutlet weak var rangeSlider: TTRangeSlider!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var fromLabel: UILabel!
@IBOutlet weak var toLabel: UILabel!
private var umt = ""
required public init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
public override func setup() {
super.setup()
rangeSlider.delegate = self
accessoryType = .None
editingAccessoryType = .None
textLabel?.text = nil
detailTextLabel?.text = nil
titleLabel.text = row.title
rangeSlider.minValue = rangeViewRow.minValue
rangeSlider.maxValue = rangeViewRow.maxValue
if let selectedMin = rangeViewRow.selectedMinimumValue {
rangeSlider.selectedMinimum = selectedMin
}
if let selectedMax = rangeViewRow.selectedMaximumValue {
rangeSlider.selectedMaximum = selectedMax
}
if let step = rangeViewRow.step {
rangeSlider.step = step
}
umt = ""
if let umtC = rangeViewRow.unitMeassureText {
umt = umtC
}
rangeSlider.enableStep = true
updateLabelsValues(rangeSlider.selectedMinimum, max: rangeSlider.selectedMaximum)
self.selectionStyle = UITableViewCellSelectionStyle.None
}
public override func update() {
super.update()
accessoryType = .None
editingAccessoryType = .None
textLabel?.text = nil
detailTextLabel?.text = nil
}
public override func didSelect() {
}
public func rangeSlider(sender: TTRangeSlider!, didChangeSelectedMinimumValue selectedMinimum: Float, andMaximumValue selectedMaximum: Float) {
updateLabelsValues(selectedMinimum, max: selectedMaximum)
}
private var rangeViewRow: RangeViewRow {
return row as! RangeViewRow
}
func updateLabelsValues(min:Float, max: Float) {
if min == rangeSlider.minValue && max == rangeSlider.maxValue {
fromLabel.hidden = false
toLabel.hidden = true
fromLabel.text = NSLocalizedString("All", comment: "Eureka range slider label if all selected")
}
else if min == rangeSlider.minValue && max != rangeSlider.maxValue {
fromLabel.hidden = true
toLabel.hidden = false
toLabel.text = NSLocalizedString("to", comment: "Eureka range slider label to") + " " + max.description + " " + umt
}
else if min != rangeSlider.minValue && max == rangeSlider.maxValue {
fromLabel.hidden = false
toLabel.hidden = true
fromLabel.text = NSLocalizedString("from", comment: "Eureka range slider label from") + " " + min.description + " " + umt
}
else {
fromLabel.hidden = false
toLabel.hidden = false
fromLabel.text = NSLocalizedString("from", comment: "Eureka range slider label from") + " " + min.description + " " + umt
toLabel.text = NSLocalizedString("to", comment: "Eureka range slider label to") + " " + max.description + " " + umt
}
row.value = "\(min):\(max)"
}
}
public final class RangeViewRow: Row<String, RangeViewCell>, RowType {
public var minValue: Float = 0.0
public var maxValue: Float = 1.0
public var selectedMinimumValue: Float?
public var selectedMaximumValue: Float?
public var unitMeassureText: String?
public var step: Float?
required public init(tag: String?) {
super.init(tag: tag)
cellProvider = CellProvider<RangeViewCell>(nibName: "RangeViewCell")
}
}
这里是如何使用它
<<< RangeViewRow("square") {
[=11=].title = NSLocalizedString("Square", comment: "Appartment square")
[=11=].minValue = 0
[=11=].maxValue = 1000
[=11=].selectedMinimumValue = 0
[=11=].selectedMaximumValue = 1000
[=11=].step = 10
[=11=].unitMeassureText = "m²"
}.cellSetup({ (cell, row) -> () in
cell.rangeSlider.handleColor = Constants.Color.primaryColor
cell.rangeSlider.lineHeight = 3.0
cell.rangeSlider.tintColor = Constants.Color.primaryColor
cell.fromLabel.textColor = UIColor.darkGrayColor()
cell.toLabel.textColor = UIColor.darkGrayColor()
})
有什么方法可以用 eureka 创建范围滑块吗?
像这样。
<<< RangeSlideRow() {
[=10=].maxValue = 10000
[=10=].minValue = 0
[=10=].selectedMaxValue = 9000
[=10=].selectedMinValue = 5
}
eureka中没有range slider,因为UISlider不支持。您将必须基于一些现有的 rangeslider 实现创建您自己的 RangeSlideRow。
查看Eureka中的SliderRow实现以供参考。
我知道我来晚了,但也许下次 this will be useful。
如果您认为对任何人都有帮助,我鼓励您在 Eureka Community 中分享您的行:) 谢谢!
这是我的做法
首次安装TTRangeSlider
然后创建了 RangeViewCell.xib 带有出口
的文件然后创建文件RangeViewCell.swift
已连接的网点
import Foundation
import UIKit
import Eureka
import TTRangeSlider
public class RangeViewCell: Cell<String>, CellType, TTRangeSliderDelegate {
@IBOutlet weak var rangeSlider: TTRangeSlider!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var fromLabel: UILabel!
@IBOutlet weak var toLabel: UILabel!
private var umt = ""
required public init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
public override func setup() {
super.setup()
rangeSlider.delegate = self
accessoryType = .None
editingAccessoryType = .None
textLabel?.text = nil
detailTextLabel?.text = nil
titleLabel.text = row.title
rangeSlider.minValue = rangeViewRow.minValue
rangeSlider.maxValue = rangeViewRow.maxValue
if let selectedMin = rangeViewRow.selectedMinimumValue {
rangeSlider.selectedMinimum = selectedMin
}
if let selectedMax = rangeViewRow.selectedMaximumValue {
rangeSlider.selectedMaximum = selectedMax
}
if let step = rangeViewRow.step {
rangeSlider.step = step
}
umt = ""
if let umtC = rangeViewRow.unitMeassureText {
umt = umtC
}
rangeSlider.enableStep = true
updateLabelsValues(rangeSlider.selectedMinimum, max: rangeSlider.selectedMaximum)
self.selectionStyle = UITableViewCellSelectionStyle.None
}
public override func update() {
super.update()
accessoryType = .None
editingAccessoryType = .None
textLabel?.text = nil
detailTextLabel?.text = nil
}
public override func didSelect() {
}
public func rangeSlider(sender: TTRangeSlider!, didChangeSelectedMinimumValue selectedMinimum: Float, andMaximumValue selectedMaximum: Float) {
updateLabelsValues(selectedMinimum, max: selectedMaximum)
}
private var rangeViewRow: RangeViewRow {
return row as! RangeViewRow
}
func updateLabelsValues(min:Float, max: Float) {
if min == rangeSlider.minValue && max == rangeSlider.maxValue {
fromLabel.hidden = false
toLabel.hidden = true
fromLabel.text = NSLocalizedString("All", comment: "Eureka range slider label if all selected")
}
else if min == rangeSlider.minValue && max != rangeSlider.maxValue {
fromLabel.hidden = true
toLabel.hidden = false
toLabel.text = NSLocalizedString("to", comment: "Eureka range slider label to") + " " + max.description + " " + umt
}
else if min != rangeSlider.minValue && max == rangeSlider.maxValue {
fromLabel.hidden = false
toLabel.hidden = true
fromLabel.text = NSLocalizedString("from", comment: "Eureka range slider label from") + " " + min.description + " " + umt
}
else {
fromLabel.hidden = false
toLabel.hidden = false
fromLabel.text = NSLocalizedString("from", comment: "Eureka range slider label from") + " " + min.description + " " + umt
toLabel.text = NSLocalizedString("to", comment: "Eureka range slider label to") + " " + max.description + " " + umt
}
row.value = "\(min):\(max)"
}
}
public final class RangeViewRow: Row<String, RangeViewCell>, RowType {
public var minValue: Float = 0.0
public var maxValue: Float = 1.0
public var selectedMinimumValue: Float?
public var selectedMaximumValue: Float?
public var unitMeassureText: String?
public var step: Float?
required public init(tag: String?) {
super.init(tag: tag)
cellProvider = CellProvider<RangeViewCell>(nibName: "RangeViewCell")
}
}
这里是如何使用它
<<< RangeViewRow("square") {
[=11=].title = NSLocalizedString("Square", comment: "Appartment square")
[=11=].minValue = 0
[=11=].maxValue = 1000
[=11=].selectedMinimumValue = 0
[=11=].selectedMaximumValue = 1000
[=11=].step = 10
[=11=].unitMeassureText = "m²"
}.cellSetup({ (cell, row) -> () in
cell.rangeSlider.handleColor = Constants.Color.primaryColor
cell.rangeSlider.lineHeight = 3.0
cell.rangeSlider.tintColor = Constants.Color.primaryColor
cell.fromLabel.textColor = UIColor.darkGrayColor()
cell.toLabel.textColor = UIColor.darkGrayColor()
})