测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年4月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Wonder Bear 维护。
一个易于使用、可定制的标签控件,可用来显示标签。
如果您不希望使用上述任何依赖管理器,可以将 WBSegmentControl 手动集成到您的项目中。
打开示例项目,构建并运行。
public protocol WBSegmentControlDelegate {
func segmentControl(segmentControl: WBSegmentControl, selectIndex newIndex: Int, oldIndex: Int)
}
public protocol WBSegmentContentProtocol {
var type: WBSegmentType { get }
}
class TextSegment: NSObject, WBSegmentContentProtocol {
var text: String!
var type: WBSegmentType {
return WBSegmentType.Text(text)
}
init(text: String) {
super.init()
self.text = text
}
}
IconSegment 和 TextSegment 已实现,您可以直接使用,无需实现 WBSegmentContentProtocol,或者您可以选择实现 WBSegmentContentProtocol 以使用您自己的标签类型。
let segmentControl = WBSegmentControl() // initialize
view.addSubview(segmentControl)
...
segmentControl.segments = [
TextSegment(text: "News China"),
TextSegment(text: "Breaking News"),
] // set segments
segmentControl.style = .Rainbow // set style
segmentControl.selectedIndex = 0 // set selected index
extension MyViewController: WBSegmentControlDelegate {
func segmentControl(segmentControl: WBSegmentControl, selectIndex newIndex: Int, oldIndex: Int) {
}
}
let selectedIndex = segmentControl.selectedIndex
let selectedSegment: TextSegment? = segmentControl.selectedSegment as? TextSegment
public var rainbow_colors: [UIColor] = []
public var rainbow_height: CGFloat = 3
public var rainbow_roundCornerRadius: CGFloat = 4
public var rainbow_location: RainbowLocation = .Down
public var rainbow_outsideColor: UIColor = UIColor.grayColor()
xiongxiong, [email protected]
WBSegmentControl 在 MIT 许可下可用。更多信息请参阅 LICENSE 文件。