HBDNavigationBar icon indicating copy to clipboard operation
HBDNavigationBar copied to clipboard

如何设置只带图片,右边不带文字的返回按钮,我设置title为空之后,但是自己的图片位置偏左

Open PengJiang520 opened this issue 2 years ago • 3 comments

代码

  • (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setupSubviews]; // self.hbd_barShadowHidden = YES; // self.hbd_barTintColor = [UIColor whiteColor]; self.hbd_barAlpha = 0.0; self.hbd_barStyle = UIBarStyleBlack; self.hbd_tintColor = UIColor.whiteColor; self.hbd_barShadowHidden = YES; self.title = @"";

}

PengJiang520 avatar Sep 05 '23 07:09 PengJiang520

这是个普遍问题,请搜索其它资料解决。通常有 runtime,BaseViewController 等方法。

listenzz avatar Sep 05 '23 07:09 listenzz

我在baseViewController 实现了此处代码,但是侧滑的手势没有响应
// TODO: 当前控制器最前面的一个不存在返回的按钮. if (self.navigationController.viewControllers.count > 1) { UIImage *leftImageName = [UIImage imageNamed:@"iv_hvac_back"]; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setFrame:CGRectMake(0, 0, leftImageName.size.width, 40)]; [backBtn setImage:leftImageName forState:UIControlStateNormal]; [backBtn setImage:leftImageName forState:UIControlStateHighlighted]; [backBtn setShowsTouchWhenHighlighted:NO]; [backBtn addTarget:self action:@selector(pb_backToPreviousViewController) forControlEvents:UIControlEventTouchUpInside]; if (ios11_0){ [backBtn setFrame:CGRectMake(0, 0, 40, 40)]; backBtn.contentEdgeInsets=UIEdgeInsetsMake(0, 0, 0, 10); } UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = item; }

  • (void)pb_backToPreviousViewController { if (self.navigationController.presentingViewController){ [self dismissViewControllerAnimated:YES completion:nil]; }else{ [self.navigationController popViewControllerAnimated:YES]; } }

PengJiang520 avatar Sep 05 '23 12:09 PengJiang520

在viewDidLoad中实现:self.navigationController.navigationBar.topItem.title = @"";

zhwIdea avatar Nov 27 '23 07:11 zhwIdea