classEbtappdelegate:uiresponder, uiapplicationdelegate {var window:uiwindow?func Application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject:anyobject]< /c2>?) -Bool {Self.window=UIWindow (Frame:UIScreen.mainScreen (). Bounds) Self.window!. BackgroundColor =Uicolor.whitecolor ()/** Home*/Let storyBoard= Uistoryboard (Name:"Main", Bundle:nil) let Firstctl= Storyboard.instantiateviewcontrollerwithidentifier ("Ebtfirstviewcontroller") as!Ebtfirstviewcontroller let Firstnav=Uinavigationcontroller (ROOTVIEWCONTROLLER:FIRSTCTL)/** Investment*/Let secondctl= Storyboard.instantiateviewcontrollerwithidentifier ("Ebtsecondviewcontroller") as!Ebtsecondviewcontroller let Secondnav=Uinavigationcontroller (ROOTVIEWCONTROLLER:SECONDCTL)/** Activities*/Let thirdctl= Storyboard.instantiateviewcontrollerwithidentifier ("Ebtthirdviewcontroller") as!Ebtthirdviewcontroller let Thirdnav=Uinavigationcontroller (ROOTVIEWCONTROLLER:THIRDCTL)/** Wealth*/Let fourctl= Storyboard.instantiateviewcontrollerwithidentifier ("Ebtfourviewcontroller") as!Ebtfourviewcontroller let Fournav=Uinavigationcontroller (rootviewcontroller:fourctl) let Navarray=[Firstnav,secondnav,thirdnav,fournav] Let Tabbarcontroller=Uitabbarcontroller () tabbarcontroller.viewcontrollers=Navarray Tabbarcontroller.selectedindex=0Let Selectimagearray= ["Tab_button_0_tap","Tab_button_1_tap","Tab_button_2_tap","Tab_button_3_tap"] Let Normalimagearray= ["tab_button_0","tab_button_1","tab_button_2","Tab_button_3"] Let Titlearray= ["Home Page","Investment","Events","Wealth"] Var count:int=0 forvar i =0; I < navarray.count;i++{var tabbaritem=Navarray[i].tabbaritem/** Shield The background color of the system, declare this picture with original (do not render)*/var normalimage=UIImage (Named:normalimagearray[i]) normalimage= Normalimage?. Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) var selectimage=UIImage (Named:selectimagearray[i]) selectimage= Selectimage?. Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) Tabbaritem.title=Titlearray[i] Tabbaritem.selectedimage=selectimage tabbaritem.image=normalimage Tabbaritem. settitletextattributes ([Nsforegroundcolorattributename:uicolor (Red:207.0/255.0, Green:44.0/255.0, Blue:65.0/255.0, Alpha:1.0), NSFontAttributeName:UIFont.boldSystemFontOfSize ( A)], forState:UIControlState.Selected)}//MARK: Set the navigation bar background colorLet Topcolor =Uicolor.redcolor () let Topimage=Uiimage.imagewithcolor (topcolor) let NavBar=uinavigationbar.appearance () navbar.setbackgroundimage (Topimage, ForBarMetrics:UIBarMetrics.Default) s Elf.window!. Rootviewcontroller =Tabbarcontroller Self.window!. makekeyandvisible ()return true }
Demo:https://github.com/kbvsmj/ebtswiftcustomtabbar
swift-Customizing the Tabbar toolbar