iOS 關於navigationBar

/** Title Text Attribute title文字的大小和顏色 */
       private static var defaultTitleTextAttribute: [String : AnyObject]? {
        
           let font = UIFont.boldSystemFontOfSize(18)
        
           let textColor = UIColor(hexString: "#FFFFFF")!
        
           return [NSFontAttributeName: font, NSForegroundColorAttributeName: textColor]
       }  


      1      // navigationBar 返回按鈕顏色
      2      self.tintColor = UIColor.redColor()
      3      // navigationBar 的顏色
      4      self.barTintColor = UIColor.yellowColor()
      5      // navigationBar上title 文字的大小顏色等
      6      self.titleTextAttributes = UINavigationBar.defaultTitleTextAttribute


            //   7 8 9 行設置navigationBar 爲透明的
      7     self.translucent = true
            
      8     self.shadowImage = UIImage()
            
      9     self.setBackgroundImage(UIImage(), forBarMetrics: .Default)

 

//  自定義navigationleftBarButtonItem 返回按鈕swift

if let viewControllers = self.navigationController?.viewControllers where viewControllers.count > 1 {
            
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "NavigationBar_Back"), style: .Plain, target: self, action: #selector(backBarButtonItemClicked))
        }


    func backBarButtonItemClicked() {
        
        self.navigationController?.popViewControllerAnimated(true)
    }
相關文章
相關標籤/搜索