iOS设置或修改导航栏按钮、标题

xiaoxiao2021-02-27  561

1. 设置导航栏返回按钮:

UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];

    button.frame = CGRectMake(0, 0, 44, 30);

    [button setImage:[UIImage imageNamed:@"leftArrow"] forState:UIControlStateNormal];

    button.imageView.contentMode = UIViewContentModeScaleAspectFit;

    [button addTarget:self action:@selector(DismissViewController:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

2. 设置导航栏背景图片:

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"grayNavBack"] forBarMetrics:UIBarMetricsDefault];

3. 取消导航栏横线:

    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

转载请注明原文地址: https://www.6miu.com/read-2401.html

最新回复(0)