Skip to content

Instantly share code, notes, and snippets.

@acalism
Created July 15, 2017 11:39
Show Gist options
  • Select an option

  • Save acalism/8a4943b89cce0ed2513e3edf84d194df to your computer and use it in GitHub Desktop.

Select an option

Save acalism/8a4943b89cce0ed2513e3edf84d194df to your computer and use it in GitHub Desktop.
navigationBar的坑
// 坑一:设置样式
// 有效的代码
navigationBar.tintColor = Color.text_light
navigationBar.shadowImage = UIImage.create(UIColor(rgb: 0xE5E5E5))
navigationBar.setBackgroundImage(UIImage.create(UIColor.white), for: .default)
navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: Color.app, NSFontAttributeName : Font.bf20]
navigationBar.setBackgroundImage(UIImage(), for: .default)
// 坑爹的代码
navigationBar.barStyle = .white // 单设有效,若有页面需改变背景,则改完复原就会灰背景————说好的白呢?
navigationBar.barTintColor = .white // 背景灰,说好的白色呢?
navigationBar.barTintColor = .clear // 背景白,说好的透明呢?
navigationBar.setBackgroundImage(nil, for: .default) // 去除背景,不一定有效
// 说来说去,还是设置backgroundImage靠谱
// 坑二:子viewController不应该设置导航栏(在统一基类的情况下,可能犯这样的错)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment