swift 修改 Navigationbar Tabbar 字體顏色背景等屬性

1.navigationBar的設置app

let navColor = UIColor(red: 41/255, green: 160/255, blue: 230/255, alpha: 1)

func setNavibar() -> Void { self.navigationController?.navigationBar.barTintColor = navColor; self.navigationController?.navigationBar.tintColor = UIColor.white; self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white,NSAttributedStringKey.font:UIFont.boldSystemFont(ofSize:20)]; self.navigationItem.backBarButtonItem = UIBarButtonItem.init(title: "", style: .plain, target: nil, action: nil); }

 

2.tabbar 的設置工具

        self.tabBar.barTintColor=UIColor.gray;
        //.設置底部工具欄文字顏色(默認狀態和選中狀態)(選中狀態爲藍色)
        UITabBarItem.appearance().setTitleTextAttributes(NSDictionary(object:UIColor.white, forKey:NSForegroundColorAttributeName as NSCopying) as? [String : AnyObject], for:UIControlState.normal);
        UITabBarItem.appearance().setTitleTextAttributes(NSDictionary(object:UIColor.blue, forKey:NSForegroundColorAttributeName as NSCopying) as? [String : AnyObject], for:UIControlState.selected)

 

tabbar 選中照片的顏色spa

    var image:UIImage = UIImage(named: imageName)!  
       var selectedimage:UIImage = UIImage(named: selectImageName)!;  
       image = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);  
      selectedimage = selectedimage.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); 
       vc.tabBarItem.image = image  
       vc.tabBarItem.selectedImage = selectedimage  
相關文章
相關標籤/搜索