UIPopupView 0.0.4

UIPopupView 0.0.4

测试已测试
语言语言 SwiftSwift
许可 MIT
发布日期最新发布2016年3月
SPM支持 SPM

AlexJones 维护。



  • Alex Jones

UIPopupView

简单来说,这原本是为了我自己使用的设计,但我认为其他人可能也会觉得它很有用。

本质上,您可以继承 UIPopupViewController 并为它们添加要显示的项目。

UIPopupViewCell 项接受一个闭包,使用某种魔法在被按下的 UIButton 上执行 block 并返回。

您也可以覆盖触摸手势,因为您肯定会在某个时候需要它们。

示例

class MyController : UIPopUpViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    self.uiPopUpViewAddControl("Circle", imageName: "circle-sprite", context:0, eventName: "uiPopUpAPressed")

    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("uiPopUpAPressed"), name: "uiPopUpAPressed", object: nil)
  }
}

结果是

Imgur

视频:http://i.imgur.com/lBybyNb.gifv

用法

我建议您继承自 UIPopupViewController,因为它已经重写了某些方法并实现了代理 - 要重写默认的代理响应,您只需实现自己的并先调用 super。

上下文悬浮

由于 UIPopupViewCell 条目具有上下文(Int),因此可以更改显示内容。在代理重写中,您可以根据触摸屏幕的位置更改当前上下文。

示例

//Here we create a delete item to appear if the context is set to one - in this case that is when we hover over a sprite
selectCell.setup("Delete", image: UIImage(named:"circle-sprite")!, onPress: { (sender) -> () in

      self.lastSelected?.removeFromParent()

}, context: 1)


//This is the override of the UIPopUpDelegate in the UIPopUpController class that is inherited

override func uiPopUpViewSelectViewContext(parentView : UIView, position: CGPoint) -> Int {

    super.uiPopUpViewSelectViewContext(parentView, position: position)

    let obj = scene!.doesNodeExist(parentView, position: position)

    if obj.bool {
    lastSelected = obj.node
         return 1
    } else {
        return 0
    }
}

自定义

UIPopupViewCell

    var view: UIView!

    @IBOutlet weak var title: UILabel!

    @IBOutlet weak var button: UIButton!

您可以进行所有正常的操作,例如修改背景颜色,设置按钮;只需查看文件了解更多信息。