iOS - 导航栏相关

自从iOS7后


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];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容