美文网首页iOS、swift技术交流!
导航栏的那些使用技巧

导航栏的那些使用技巧

作者: 光明程辉 | 来源:发表于2016-02-05 14:19 被阅读88次

    本来我的statusbar是lightcontent的,结果用UIImagePickerController会导致我的statusbar的样式变成黑色,怎么办?

      - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    }
    

    怎么把我的navigationbar弄成透明的而不是带模糊的效果?

    [self.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.shadowImage = [UIImage new];
    self.navigationBar.translucent = YES;
    

    文/叶孤城___(简书作者)
    原文链接:http://www.jianshu.com/p/08f194e9904c

    UIImageView默认的userInteractionEnabled = NO.所以要想图片中的按钮被点击需要设置

    imageView.userInteractionEnabled = YES;

    定制导航栏的返回按钮

    // 隐藏默认的"返回"按钮
    [self.navigationItem setHidesBackButton:YES];

    // 自定义导航栏的"返回"按钮
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(15, 5, 35, 35);
    
    [btn setBackgroundImage:[UIImage imageNamed:@"photo_left_nav"] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(goBackAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * back=[[UIBarButtonItem alloc]initWithCustomView:btn];
    // 设置导航栏的leftButton
    
    self.navigationItem.leftBarButtonItem=back;

    相关文章

      网友评论

        本文标题:导航栏的那些使用技巧

        本文链接:https://www.haomeiwen.com/subject/muzfkttx.html