测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
Released最新版本 | 2016年10月 |
SPM支持 SPM | ✗ |
Maintained by Kaunteya Suryawanshi.
KSTabView
是一个简单、轻量级的为 Mac OSX 实现的 Swift TabView
将 KSTabView.swift
拖动到您的项目中。
在 IB 中,从对象库中拖动一个自定义视图。将自定义类设置为 KSTabView。
将 IBOutlet 拖动到 ViewController 中
@IBOutlet weak var tabView: KSTabView!
按钮可以左对齐或右对齐
tabView.pushButtonLeft("Reload", identifier: "reload") // Adds Button with title "Reload" and identifier "reload" aligned Left
tabView.pushButtonRight("Jump", identifier: "jump")
标识符是必须的,因为动作事件会将此标识符字符串作为参数接收
处理按钮点击就像在视图中创建一个 IBAction 一样简单
@IBAction func actionOccured(sender: NSString?) {
println("\(sender) pressed") // Prints the identifier of button that is clicked
}
可以移除按钮,以便可以添加新的按钮
tabView.removeLeftButtons() //Removes all the Left aligned buttons
tabView.removeRightButtons() //Removes all the Right aligned buttons
KSTabview 有 3 种操作模式,即 None
,One
和 Any
tabView.selectionType = .None // No selection happens.(Only action triggers)
tabView.selectionType = .One // Only the latest selection stays
tabView.selectionType = .Any // Multiple buttons can be selected
不打算返回任何内容的方法返回 self,以便 facilitating method chaining
tabView.removeRightButtons()
.pushButtonRight("Help", identifier: "help")
.pushButtonRight("Modify", identifier: "modify")
.pushButtonRight("Delete", identifier: "delete")
.pushButtonRight("New", identifier: "new").selectedButtons = ["modify"]