聽說Swift5趨于穩(wěn)定了。湊空看了下Swift,寫了個簡單的demo:https://github.com/lihui1314/LHPromptBoxTool
效果圖如下:

1550935814763.jpg
做了簡單的封裝,代碼調(diào)用起來也很方便,如下:
@objc func btnAction(sender:UIButton) -> Void {
let prompt = LHPromptBoxView()
let mode1 = LHPromptModel()
mode1.name = "Apple"
let mode2 = LHPromptModel()
mode2.name = "Google"
let mode3 = LHPromptModel()
mode3.name = "Cancel"
mode3.color = UIColor.red
prompt.modelArray = [mode1,mode2,mode3]
prompt.lh_show()
prompt.delegate = self
//如果有閉包的實現(xiàn),會優(yōu)先執(zhí)行閉包,沒有閉包實現(xiàn)的話會下面的代理,二者選一即可
prompt.selectBlock = {(index:Int)->Void in
print(index)
}
}
//點擊代理方法
func lh_didSelet(index: Int) {
print(index)
}