Uitbarcontroller before in this article explains: http://www.cnblogs.com/niit-soft-518/p/4447940.html
If you have customized the image of Uitabbaritem, when you create it with the above article, we find that the border color of the selected chart is blue by default.
To solve this problem, we need to set the rendering mode of UIImage
Imagewithrenderingmode
set the rendering mode for UIImage: Uiimage.renderingmode Coloring (Tint Color) is one of the iOS7 interfaces. Set the rendering mode of the UIImage: Uiimage.renderingmode A significant change, you can set a UIImage whether to use the tint Color of the current view when rendering. UIImage added a read-only property: Renderingmode, corresponding to a new method: Imagewithrenderingmode:, It uses the Uiimagerenderingmode enumeration value to set the Renderingmode property of the picture. The enumeration contains the following values: Uiimagerenderingmodeautomatic // automatically adjusts the rendering mode based on the environment in which the picture is used and the drawing context in which it is located. Uiimagerenderingmodealwaysoriginal // always draws the original state of the picture without using tint Color. Uiimagerenderingmodealwaystemplate // always draws a picture based on tint color, ignoring the color information of the picture.
If you want to use the custom color of the selected chart, you need to set uiimagerenderingmodealwaysoriginal. Example: Uitabbaritem *tabbar; TabBar. SelectedImage =[[uiimage imagenamed:@ "Bar_icon.png"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];
//Initialize Controllers{Fourviewcontroller*one=[[Fourviewcontroller alloc]init]; Uitabbaritem*itemone=[[uitabbaritem Alloc]initwithtitle:@"message"Image:[uiimage imagenamed:@"Btn_message_nor"] Selectedimage:[[uiimage imagenamed:@"Btn_message_sel"]imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]]; One.tabbaritem=ItemOne; [ItemOne settitletextattributes:[nsdictionary Dictionarywithobject:kdefault_coloe ForKey: Nsforegroundcolorattributename] forstate:uicontrolstatehighlighted]; [Controllers Addobject:one]; } {Fiveviewcontroller*five=[[Fiveviewcontroller alloc]init]; Uitabbaritem*itemfive=[[uitabbaritem Alloc]initwithtitle:@"my own"Image:[uiimage imagenamed:@"Btn_me_nor"] Selectedimage:[[uiimage imagenamed:@"Btn_me_sel"] [imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]]; Five.tabbaritem=itemfive; [Itemfive settitletextattributes:[nsdictionary Dictionarywithobject:kdefault_coloe ForKey: Nsforegroundcolorattributename] forstate:uicontrolstatehighlighted]; [Controllers addobject:five]; }
IOS Uitabbaritem Select the color of the chart, set the UIImage rendering mode