@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