1、在UIView 上面 拖上 navigationBar ,navigationItem ,BarButtonItem
@IBOutlet weak var navTitle: UINavigationItem!
@IBOutlet weak var navBar: UINavigationBar!
@IBOutlet weak var settingBtn: UIBarButtonItem!
//设置navigation 背景颜色 为透明
navBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
navBar.shadowImage = UIImage()
navBar.translucent = true
//设置navigation 显示层为 绿色
let greenColor:UIColor = UIColor(red:75/255,green: 163/255,blue: 75/255,alpha:1)
navBar.layer.backgroundColor=greenColor.CGColor
//设置 tite 的字体和颜色
navBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name:"Helvetica",size:22.0)!]
//设置nav button 为图标
settingBtn.tintColor=UIColor.whiteColor()
settingBtn.setTitleTextAttributes([NSFontAttributeName:FontAwesomeIcon.getFontAwesome(18)], forState: UIControlState.Normal)
settingBtn.title=FontAwesomeIcon.getFontICO("fa-cog")
//设置 SearchBar
let searchBar:UISearchBar = UISearchBar(frame: CGRectMake(0, 0, 150, 20))
searchBar.placeholder = "搜索实验..."
let rightNavBarButton = UIBarButtonItem(customView:searchBar)
navTitle.rightBarButtonItem = rightNavBarButton
2. 在swift中使用 FontAwesome 添加 FontAwesome.ttf 和 相应的.swift 文件
注意在info.plist 中添加 Fonts provided by application 并添加 item 的值为 FontAwesome.ttf