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

来源:互联网 发布:网络信息科技经营范围 编辑:程序博客网 时间:2024/06/05 19:04
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.navigationBarsetBackgroundImage:[UIImageimageNamed:@"grayNavBack"]forBarMetrics:UIBarMetricsDefault];


3. 取消导航栏横线:

    [self.navigationController.navigationBarsetShadowImage:[UIImagenew]];




0 0