现在的位置: 首页 > 综合 > 正文

ios leftBarButtonItem 使用图片

2019年08月28日 ⁄ 综合 ⁄ 共 477字 ⁄ 字号 评论关闭

   有些时候,我们需要将leftBarButtonItem使用图片代替文字如“菜单”按钮,可以使用如下代码即可实现

 UIButton *TastoVersamento = [UIButton buttonWithType:UIButtonTypeCustom];

 [TastoVersamento setImage:[UIImage imageNamed:@"ICON_menu"] forState:UIControlStateNormal];

 [TastoVersamento addTarget:self action:@selector(showMenu:) forControlEvents:UIControlEventTouchUpInside];

 [TastoVersamento setFrame:CGRectMake(0, 0, 40, 40)];

 viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:TastoVersamento];

抱歉!评论已关闭.