Use the system's Tabbar to solve the picture problem.
Using SB to use the system's Tabbar, and found that the picture is always blue, not the original picture, after the Internet to check data, ask colleagues, with the following code, make a mark.
In Appdelegate
Func application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [Nsobject:anyobject]?)- > Bool {
Inittabbarselecteditem ()
return True
}
Func Inittabbarselecteditem ()
{
var Rootcontroller = Self.window?. Rootviewcontroller as Uitabbarcontroller
var TabBar = Rootcontroller.tabbar
var Homeitem = Tabbar.items? [0] as uitabbaritem var selectedimg = UIImage (named: "Home")? Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) If Homeitem.tag = = {Homeitem.selectedimage = Selectedimg homeitem.settitletextattributes ([NSForegroundColorAttributeName:UIColor.redColor (), NSFontAttributeName:UIFont.systemFontOfSize], ForState:UIControlState.Normal)} var orderitem = Tabbar.items? [1] as uitabbaritem var orderitemimg = UIImage (named: "Order")?. Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) If Orderitem.tag = = 101 {orderitem.selectedimage = Orderitemimg Orderitem.settitletextattributes ([NSForegroundColorAttributeName:UIColor.redColor ()], Forstate:uic ontrolstate.selected)} var releaseitem = Tabbar.items? [2] as uitabbaritem var releaseitemimg = UIImage (named: "Publish")?. Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) If Releaseitem.tag = = 102 {ReleaseItem.selectedI MagE = releaseitemimg Releaseitem.image = releaseitemimg releaseitem.settitletextattributes ([NSForegroundColorAttri ButeName:UIColor.redColor ()], forState:UIControlState.Selected)} var myitem = Tabbar.items? [3] as uitabbaritem var myitemimg = UIImage (named: "My")?. Imagewithrenderingmode (uiimagerenderingmode.alwaysoriginal) if Myitem.tag = = 103 {myitem.selectedimage = MyI Temimg myitem.settitletextattributes ([NSForegroundColorAttributeName:UIColor.redColor ()], forstate: uicontrolstate.selected)}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Tabbarcontroller of the use system for swift development