Reputation: 78
I'm trying to add custom image to tabview controller, its working fine for me this is code I'm using
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"Home-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Home.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"MyTc-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"MyTc.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"Browse-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Browse.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"Instore-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Instore.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:4] setFinishedSelectedImage:[UIImage imageNamed:@"More-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"More.png"]];
the image not fit into the tabbar
out put
there is some design issue is there how can I fix this
Image goes over the tabbar, and some other background image is showing in selected tab (check 2nd tab).
How can I fix this
Upvotes: 0
Views: 394
Reputation: 6079
to lower the images in the TabBar could change the imageInsets:
try something like that:
UITabBarItem *tabBarItem1 = [AppDelegate.Tabctrl.tabBar.items objectAtIndex:0];
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"Home-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Home.png"]];
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
Upvotes: 2