KSTabView 0.4.0

KSTabView 0.4.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最新版本2016年10月
SPM支持 SPM

Maintained by Kaunteya Suryawanshi.



KSTabView 0.4.0

  • Kaunteya Suryawanshi

KSTabView

KSTabView 是一个简单、轻量级的为 Mac OSX 实现的 Swift TabView

特性

  • 完整的自动布局支持
  • 所有配置均可通过 IBInspecatable 验证
  • 简单轻量

要求

  • Mac OS X 10.10+
  • Xcode 6.3

使用

设置

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 种操作模式,即 NoneOneAny

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"]

待办事项

  • 允许从 Interface Builder 添加按钮
  • 文档
  • 支持带有图像的按钮