为了点击右边的BarbuttonItem,实现下拉菜单的效果;我们选择用PopMenu来试下如下效果:
image.png
首先建立items并把items导入Menu中:
let items = [
MenuItem(title: "客服", iconName: nil, glowColor: UIColor.redColor(), index:0),
MenuItem(title: "与熊聊天", iconName: nil, glowColor: UIColor.blueColor(), index:1),
MenuItem(title: "通讯录", iconName: nil, glowColor: UIColor.yellowColor(), index:2),
MenuItem(title: "关于", iconName: nil, glowColor: UIColor.yellowColor(), index:3) ]
let menu = PopMenu(frame: self.view.bounds, items: items)
menu.menuAnimationType = .NetEase
if menu.isShowed {
return
}
其次实现选择该item时的动作,例如点击与某人聊天后跳转到聊天界面并传值:
menu.didSelectedItemCompletion = {
(selectedItem: MenuItem!) -> Void in
switch selectedItem.index {
case 1:
let conVC = RCConversationViewController()
conVC.targetId = "xiong"
conVC.userName = "熊"
conVC.conversationType = RCConversationType.ConversationType_PRIVATE
conVC.title = conVC.userName
self.navigationController?.pushViewController(conVC, animated: true)
self.tabBarController?.tabBar.hidden = true
default:
print(selectedItem.title)
}
}
menu.showMenuAtView(self.view)
}
网友评论