当前位置: 首页 > 工具软件 > KxMenu > 使用案例 >

使用kxmenu时在UIBarButtonItem上frame无效

柳翼
2023-12-01
UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addBtnClicked:event:)];
    
    self.navigationItem.rightBarButtonItem = addItem;
//添加按钮点击触发事件,弹出下拉菜单
-(void)addBtnClicked:(UIBarButtonItem *)sender event:(UIEvent *) event
{
    NSArray *menuItems =
    @[
      
      [KxMenuItem menuItem:@"一键报送"
                     image:[UIImage imageNamed:@"导航栏-搜索"]
                     target:self
                    action:@selector(kxMenuClicked:)],
      
      [KxMenuItem menuItem:@"风险地图"
                     image:[UIImage imageNamed:@"导航栏-搜索"]
                     target:self
                     action:@selector(kxMenuClicked:)],
      
      [KxMenuItem menuItem:@"友情链接"
                     image:[UIImage imageNamed:@"导航栏-搜索"]
                     target:self
                     action:@selector(kxMenuClicked:)]
      ];
    
    CGRect fromRect = [[event.allTouches anyObject] view].frame;
    fromRect.origin.y += 20;

    [KxMenu setTitleFont:[UIFont systemFontOfSize:16]];
    [KxMenu showMenuInView:self.navigationController.navigationBar.superview
                  fromRect:fromRect
                 menuItems:menuItems];
}


 类似资料: