ActionsDrawer 0.1.1

ActionsDrawer 0.1.1

Fine crafted apps 维护。



  • 作者
  • Francis

ActionsDrawer

CI Status Version License Platform

它的外观是怎样的?

如何使用

// Using the hardcoded title approach

func present() {
    let drawerViewController = ActionsDrawerViewController(title: "Title provided as a string", actionGroups: [
        ActionGroup(actions: [
            Action(icon: nil, title: "Do the thing", tintColor: .blue, handler: {
                print("Did the thing")
            }),
            Action(icon: nil, title: "Do the other thing", tintColor: .blue, handler: {
                print("Did the other thing")
            })
        ]),
        ActionGroup(actions: [
            Action(icon: nil, title: "Do the dangerous thing thing", tintColor: .red, handler: {
                print("Did the dangerous thing")
            })
        ])
    ])
    self.drawerController = drawerViewController
    drawerViewController.delegate = self
    drawerViewController.transitioningDelegate = drawerViewController
    present(drawerViewController, animated: true, completion: nil)
}

// Using the protocol approach

struct Pizza {
    let radius: Int
    let toppings: [String]
}

extension Pizza: ActionableItem {
    var drawerView: UIView {
        let view = UILabel()
        view.text = "\(radius) inch pizza - \(toppings.count) toppings"
        view.textColor  = UIColor.orange
        view.font = UIFont.systemFont(ofSize: 14)
        view.textAlignment = .center
        return view
    }
}

// ...

func present() {
    let pizza = Pizza(radius: 12, toppings: ["Pepperonni", "Cheese"])

    let viewController = ActionsDrawerViewController(actionableItem: pizza, actionGroups: [
        ActionGroup(actions: [
            Action(icon: UIImage(named: "oven"), title: "Bake", tintColor: .blue, handler: {
                print("Baking the pizza")
            }),
            Action(icon: UIImage(named: "pizzaCar"), title: "Deliver", tintColor: .blue, handler: {
                print("Delivering the pizza")
            })
        ]),
        ActionGroup(actions: [
            Action(icon: UIImage(named: "garbage"), title: "Garbage", tintColor: .red, handler: {
                print("Pizza tastes bad. Putting in the garbage")
            })
        ])
    ])
}

示例

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

要求

安装

ActionsDrawer 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ActionsDrawer'

作者

Francis,[email protected]

许可证

ActionsDrawer 基于 MIT 许可证提供。更多信息请参阅 LICENSE 文件。