Add UIButton as a Subtitle to UITabBar

I am trying to implement a hidden UITabBar in my application. I have configured all the animations and they work very well. I just have a problem with my UIButton "pull-tab" tab to show the tab bar. It does not respond to the UIControlEventTouchUpInside touch event. I add pull-tab to UITabBar in UITabBarController:

- (void)viewDidLoad { [super viewDidLoad]; //Add pull pullButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *image = [UIImage imageNamed:@"TabBarPull.png"]; pullButton.frame = CGRectMake(self.tabBar.frame.size.width - image.size.width, -image.size.height + 3, image.size.width, image.size.height); [pullButton setImage:image forState:UIControlStateNormal]; [pullButton addTarget:self action:@selector(pullBarTapped:) forControlEvents:UIControlEventTouchUpInside]; pullButton.userInteractionEnabled = YES; [self.tabBar addSubview:pullButton]; } 

Here's what the tab bar looks like open and closed:

TabBar not hiddenTabbar hidden

Edit: I decided that the problem is that the button is beyond the scope of the UITabBar. It looks like I will need to put a button outside of the UITabBar ... An animated nightmare.

+8
ios uibutton uiview uitabbarcontroller uitabbar
source share
2 answers

You can add UIButton to the main view of UITabBarController , but not to UITabBar , though .... [myUITabBarController.view addSubview:pullButton]

+12
source share

Since you have the hiding part working in UITabbar, and from the answer I saw here, you could save the UIButton inside the UITabbar, but also add a button to the view when the UITabbar is hidden (so you will have two buttons that overlap) . When a tab is displayed, hide the button added to the view using the property hidden in the view.

0
source share

All Articles