UI高度可定製化KxMenu彈出選單
阿新 • • 發佈:2019-02-01
效果如下:
與QQ自帶彈出選單對比:
用法:
選單內容設定
let menuArray = [KxMenuItem.init("掃一掃", image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:"),
KxMenuItem.init("加好友", image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:"),
KxMenuItem.init("建立討論組" , image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:"),
KxMenuItem.init("傳送到電腦", image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:"),
KxMenuItem.init("面對面快傳", image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:"),
KxMenuItem.init ("收錢", image: UIImage(named: "Touch"), target: self, action: "respondOfMenu:")]
選單UI設定
//配置一:基礎配置
KxMenu.setTitleFont(UIFont(name: "HelveticaNeue", size: 15))
//配置二:拓展配置
let options = OptionalConfiguration(arrowSize: 9, //指示箭頭大小
marginXSpacing: 7, //MenuItem左右邊距
marginYSpacing: 9, //MenuItem上下邊距
intervalSpacing: 25, //MenuItemImage與MenuItemTitle的間距
menuCornerRadius: 6.5, //選單圓角半徑
maskToBackground: true, //是否新增覆蓋在原View上的半透明遮罩
shadowOfMenu: false, //是否新增選單陰影
hasSeperatorLine: true, //是否設定分割線
seperatorLineHasInsets: false, //是否在分割線兩側留下Insets
textColor: Color(R: 0, G: 0, B: 0), //menuItem字型顏色
menuBackgroundColor: Color(R: 1, G: 1, B: 1) //選單的底色
)
選單彈出方法
KxMenu.showMenuInView(self.view, fromRect: sender.frame, menuItems: menuArray, withOptions: options)