pod 'CLMenuItem'
lazy var menuItem:CLMenuView = {
let menuItem = CLMenuView(itemTypes: [.copy,.collect,.reply,.report,.resend,.translate])
menuItem.delegate = self
return menuItem
}()
guard let keyWindow = UIApplication.shared.delegate?.window else {return}
if menuItem.alpha == 0 {
keyWindow?.addSubview(self.menuItem)
}
把需要添加view的frame 转化到keyWindow上
let rect = cell?.contentView.convert((cell?.contentView.frame)!, to: keyWindow)
menuItem.setTargetRect(targetRect: rect!)
menuItem.showMenuItemView(indexPath: indexPath)
func menuItemAction(item: NSInteger) {
print("=====Index = \(item)")
}
clickMenuitemIndex:((_ indexPath:IndexPath,_ itemIndex:Int)->())
显示
menuItem.showMenuItemView(indexPath:IndexPath)
隐藏
menuItem.hiddenMenuItemView()