Development environment: Xcode 6.1 iOS 7.1.2 & iOS 8.1
Implement function One, the third tab corresponding view is displayed when the app is opened;
Implement function Two, set the picture for each tab and select the picture.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Override point for customization after application launch. --------------------------------------------- //Set the first view as Camera view and custom tab bar //------- -------------------------------------- [self settabbar];}
Implement Settab Bar:
---------------------------------------------#pragma mark-tab bar//------------------------------------------- ---(void) settabbar{Uitabbarcontroller *tabviewcontroller = (Uitabbarcontroller *) Self.window.rootViewController; [Tabviewcontroller Setselectedindex:2]; Uitabbar *tabbar = Tabviewcontroller.tabbar; [TabBar settintcolor: [Uicolor Greencolor]]; First Uitabbaritem *tabbaritem1 = [Tabbar.items objectatindex:0]; uiimage* tabbaritem1image = [UIImage imagenamed:@ "XXX"]; UIImage *scaledtabbaritem1image = [UIImage imagewithcgimage:[tabbaritem1image cgimage] Scale: (Tabbaritem1image.scale * 3) Orientation: (tabbaritem1image.imageorientation)]; uiimage* tabbaritem1selectedimage = [UIImage imagenamed:@ "XXX"]; UIImage *scaledtabbaritem1selectedimage = [UIImage imagewithcgimage:[tabbaritem1selectedimage cgimage] Scale: ( Tabbaritem1selectedimage.scale * 3) Orientation: (tabbaritem1selectedimage.imageorientation)]; (void) [TabBarItem1 initwithtitle:@]First "Image:scaledtabbaritem1image Selectedimage:scaledtabbaritem1selectedimage]; Second Uitabbaritem *tabbaritem2 = [Tabbar.items objectatindex:1]; uiimage* tabbaritem2image = [UIImage imagenamed:@ "XXX"]; UIImage *scaledtabbaritem2image = [UIImage imagewithcgimage:[tabbaritem2image cgimage] Scale: (Tabbaritem2image.scale * 3) Orientation: (tabbaritem2image.imageorientation)]; uiimage* tabbaritem2selectedimage = [UIImage imagenamed:@ "XXX"]; UIImage *scaledtabbaritem2selectedimage = [UIImage imagewithcgimage:[tabbaritem2selectedimage cgimage] Scale: ( Tabbaritem2selectedimage.scale * 3) Orientation: (tabbaritem2selectedimage.imageorientation)]; (void) [TabBarItem2 initwithtitle:@ "Second" Image:scaledtabbaritem2image selectedimage:scaledtabbaritem2selectedimage]; and Others Tabs-the same way}
in the didfinishlaunchingwithoptions a custom jump directly to a tab:
Uitabbarcontroller *tabviewcontroller = (Uitabbarcontroller *) Self.window.rootViewController; [Tabviewcontroller Setselectedindex:2];
To keep the pixels sharp, make the icons clearer, use large pictures, and then use the code to narrow them down:
[UIImage imagewithcgimage:[tabbaritem1image Cgimage] Scale: (Tabbaritem1image.scale * 3) Orientation: ( Tabbaritem1image.imageorientation)];
another:
Because the selected image system will always set the picture to tint color, the default is blue, so you need to set your own color:
[TabBar settintcolor: [Uicolor Greencolor]];
Reference Links:
Http://stackoverflow.com/questions/18894985/uitabbar-not-showing-selected-item-images-in-ios-7
http://stackoverflow.com/a/19386156/3458781
http://www.appcoda.com/ios-programming-how-to-customize-tab-bar-background-appearance/
IOS Sets the tab Bar in Tabviewcontroller and implements the custom