系统导航栏部分简单研究

在研究一下导航栏的时候,想要只用系统的动画,因而发现了一些问题

无法使用系统返回手势

添加delegate

__weak typeof (self) weakSelf = self;

    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.interactivePopGestureRecognizer.delegate = weakSelf;

    }

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

{

    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.interactivePopGestureRecognizer.enabled = animated;

    }

    

    [super pushViewController:viewController animated:animated];

}

导航栏添加照片:

 [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"big4ads_banner02.png"] forBarMetrics:UIBarMetricsDefault];


一些ViewController手势冲突,添加delegate

  self.navigationController.delegate=self;


- (void)navigationController:(UINavigationController *)navigationController

       didShowViewController:(UIViewController *)viewController

                    animated:(BOOL)animated

{

    if ([viewController isKindOfClass:self.class]) {

        navigationController.interactivePopGestureRecognizer.enabled = NO;

    }else if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        navigationController.interactivePopGestureRecognizer.enabled = YES;

    }

}

iOS 7以上系统修改title文字大小,颜色

[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, [UIFont fontWithName:@ "HelveticaNeue-CondensedBlack" size:18.0], NSFontAttributeName, nil]];

导航栏UIBarButtonItem的修改

UIButton *clearButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];

    clearButton.tintColor =[UIColor blackColor];

    UIImage *image =[UIImage imageNamed:@"delete"];

    image=[image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

    [clearButton setImage:image forState:UIControlStateNormal];

    [clearButton addTarget:self action:@selector(removeAllMessages:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:clearButton];

[[UIBarButtonItem appearance]setTintColor:[UIColor blackColor]];

上传一张结构图用来研究修改

系统返回按钮的修改需要在上一层修改。

self.navigationItem.backBarButtonItem=back;

系统返回按钮title会使用上一层的title,如果title长度过长,会使用系统语言的“返回”。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值