iOS - 导航栏相关

自从iOS7后


iOS - 导航栏相关_第1张图片
image.png
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;

隐藏导航栏下面的线

 [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
 //消除阴影
 self.navigationController.navigationBar.shadowImage = [UIImage new];

调整导航栏按钮间距

    UIBarButtonItem *fixedButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    fixedButton.width = -15;
    
    UIButton *rightBtn = MakeTextButtonWith(17, BlackColor, @"我的文件", kClearColor);
    CGFloat litleMargin  = (Px30Distance);
    [rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
    CGFloat rightBtnW = (WidthOfLabel(Pt15FontSize, @"我的文件") +litleMargin * 2);
    rightBtn.frame = CGRM(kScreenWidth - rightBtnW - Px30Distance + litleMargin, 20, rightBtnW, 44);
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItems = @[fixedButton ,rightBarButtonItem];

你可能感兴趣的:(iOS - 导航栏相关)