问题
I know how to add UITabBarController
and how it is used, I already done it.
My Problem is that I am not able to add image on 'more'
tab of UITabBarController
.
I know there are many similar questions as mine but did not help me.
After googling I found that we can't add images on 'More'
tab in UITabBarController
Because more
tab is automatically displayed by UITabBarController
when UITabBarItem
is more Then 5.
I could find how to change SELECTION COLOR AND TITLE OF 'more'
button, But I could not find about 'more'
button Image.
So may be I need to customize UITabBarController
so, I am also searching for customization of UITabBarController
but could not find it.
Please help me on this Issue.
回答1:
More button is automatically generate when tabs are more than 5 in iPhone. So you can't do that. Instead you should make a custom tabbar with the help of UIView
and UIButton
s.
See how to add UIViewController
's view on self.view
.
[self addChildViewController:yourViewController];
yourViewController.view.frame = anyFrame;
[self addSubview:yourViewController.view];
[yourViewController didMoveToParentViewController:self];
By this you can add different UIViewController
on each button's click. All the best!
Well If you dont want to create it yourself. Below is the list of custom tabbars find the one which suits your requirement.
- AKTabBarController
- InfiniTabBar
- RaisedCenterTabBar
- MHTabBarController
- TweetBotTabBar
- ALCustomTabBarController
- MHCustomTabBarController
- M13InfiniteTabBar
- TabBarKit
- RNSwipeBar
- BCTabBarController
- TabBarAnimation
- ExpandableTabBar
- JBTabBarController
- JSScrollableTabBar
- NGTabBarController
- crtabbar
- VSTabBar
- DMFilterView
- CubeTabBarController
- FSVerticalTabBarController
- PrettyKit
回答2:
You can add an image for each item , for the selected and unselected states. Like this:
UIImage *selectedImage0 = [UIImage imageNamed:@"image1.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"image1_unselected.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"image2.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"image2_unselected.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"image3.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"image3_unselected.png"];
UIImage *selectedImage3 = [UIImage imageNamed:@"image4.png"];
UIImage *unselectedImage3 = [UIImage imageNamed:@"image4_unselected.png"];
UIImage *selectedImage4 = [UIImage imageNamed:@"image5.png"];
UIImage *unselectedImage4 = [UIImage imageNamed:@"image5_unselected.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
UITabBarItem *item4 = [tabBar.items objectAtIndex:4];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
[item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3];
[item4 setFinishedSelectedImage:selectedImage4 withFinishedUnselectedImage:unselectedImage4];
You can place this code in the viewDidLoad method of any of your controllers.
Hope it works for you thanks!
回答3:
Try to create more than 5 segues from TabBarController to others and than you will see more button. Add images on the TabBar item of each controller you were connected and you will see this tabbar item's icon on the main TabBar
来源:https://stackoverflow.com/questions/17311489/how-to-add-image-on-more-button-of-uitabbarcontroller-in-ios-6