NavigationItem 调整间距及导航栏的背景颜色

设置间距

let space = UIBarButtonItem.init(barButtonSystemItem: .fixedSpace, target: nil, action: nil)

space.width = 20

添加间距到item

navigationItem.rightBarButtonItems = [space,OtherItem]

背景颜色设置

navigationController?.navigationBar.barTintColor = .red

navigationController?.navigationBar.barStyle = .blackTranslucent

Item颜色及中间title颜色

navigationController?.navigationBar.tintColor = .white

navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: .red]

你可能感兴趣的:(NavigationItem 调整间距及导航栏的背景颜色)