Swiftpack.co - Package - HongliYu/DPEdgeMenu-Swift

DPEdgeMenu-Swift

simple menu appear from four directions of screen edge

Cocoapods Pod License Swift-4.2 Carthage Compatible

screenshot

Usage

  // 1. Make an array of related buttons
  
    var buttons = [UIButton](https://raw.github.com/HongliYu/DPEdgeMenu-Swift/blob/master/)
    let letters = ["A", "B", "C", "D"]
    let colors = [UIColor(red: 237.0 / 255.0, green: 140.0 / 255.0, blue: 52.0 / 255.0, alpha: 1.0),
                  UIColor(red: 140.0 / 255.0, green: 155.0 / 255.0, blue: 237.0 / 255.0, alpha: 1.0),
                  UIColor(red: 237.0 / 255.0, green: 140 / 255.0, blue: 200.0 / 255.0, alpha: 1.0),
                  UIColor(red: 237.0 / 255.0, green: 100.0 / 255.0, blue: 100.0 / 255.0, alpha: 1.0)]
    let items = zip(letters, colors).map { $0 }
    for item in items.enumerated() {
      let button = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
      button.setTitleColor(.white, for: .normal)
      button.setTitle(item.element.0, for: .normal)
      button.backgroundColor = item.element.1
      button.tag = item.offset
      button.addTarget(self, action: #selector(doAction(_:)), for: .touchUpInside)
      buttons.append(button)
    }

  
  // 2. Cconfig basic params
    edgeMenu.config(buttons)
    edgeMenu.animationDuration = 0.8
    edgeMenu.menuPosition = .right
    edgeMenu.open()

    view.setMenu { [weak self] gesture in
      guard let strongSelf = self else { return }
      strongSelf.updateSideBar()
    }
    
    view.addSubview(edgeMenu)
    view.backgroundColor = UIColor(red: 86 / 255.0, green: 202 / 255.0,
                                   blue: 139 / 255.0, alpha: 1.0)
}

Github

link
Stars: 21

Dependencies

Used By

Total: 0