SuperButton 1.0.7

SuperButton 1.0.7

Kraig Wastlund 维护。



SuperButton

CI Status Version License Platform

示例

动态-
picture
三个按钮 四个按钮 五个按钮 六个按钮 七个按钮
picture picture picture picture picture

要运行示例项目,请先克隆仓库,然后从 Example 目录中运行 pod install

要求

  • iOS > 8.2
  • 支持的最大按钮数 = 7

安装

SuperButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 即可

pod 'SuperButton'

用法

import SuperButton

class ViewController: UIViewController {

    var superButtonView: SuperButtonView!

    @IBOutlet weak var actionLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        // ... create the super button and give the main button the color you'd like
        let mainButtonColor = UIColor(red: 0/255, green: 21/255, blue: 211/255, alpha: 1.0)
        superButtonView = SuperButtonView(nodes: nodes(), mainButtonColor: mainButtonColor)
        setup()
    }

    private func setup() {
        // ... constrain / setup ui elements how you'd like
        // ... you can use frame/storyboard if you'd like
        // ... buttons always have a static width and space out from center
    }

    private func fadeDisplayText(text: String) {
        // ... displays text in a cool way :)
    }

    private func nodes() -> [SuperNodeView] {
        var nodes = [SuperNodeView]()

        // ... note that the main button takes a color and the `node` buttons take an image.

        // ... you can instantiate a node this way:
        nodes.append(SuperNodeView(title: "Node 1", image: #imageLiteral(resourceName: "1"), completion: { [weak self] in self?.fadeDisplayText(text: "Node 1 Triggered") }))

        // ... or like this:
        let node2 = SuperNodeView()
        node2.title = "Node 2"
        node2.image = #imageLiteral(resourceName: "2")
        node2.completion = { [weak self] in self?.fadeDisplayText(text: "Node 2 Triggered") }
        nodes.append(node2)

        // ... add more buttons at your leisure

        return nodes
    }
}

作者

kraigwastlund,[email protected]

许可协议

SuperButton 在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。