Customizing the More menu on a Tab bar
visibleCells is populated only after the moreNavigationController is displayed.
And the cells are created at runtime, so even if you change the content of the cells, they are replaced when they are displayed.
One thing to try would be to replace the datasource of the moreNavigationController tableView, call the cellForRowAtIndexPath of the original datasource and change its content before returning it.
Using the code below, after having displayed once the moreNavigationController to initialize it, you'll see that when you return to the moreNavigationController, the cells are red, but return immediately to white background.
UITableView *view = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view;
if ([[view subviews] count]) {
for (UITableViewCell *cell in [view visibleCells]) {
cell.backgroundColor = [UIColor redColor];
}
}
How to set the more tab bar's edit view's navigation bar black?
The link has a slightly hackie solution that involves listening to when the modal view will appear.
Colouring fun with moreNavigationController
Until iOS5+ enables us to do it in a cleaner way.
How to configure the More menu on the tab bar
Yes, you can reposition tabs. Just drag the icon you want down to the UITabBar and it will replace for the icon you drop over.
iPhone : Custom tabbar without the awful More menu
I should finalize this thread. I have been having the stuff above in a App Store for a year and it has caused massive problems in the long run. It works, but it quirks when you rely on the built in features of UITabbarcontroller as it messes around with the view stack.
After going around this hot ash for over a year we decided to build our own tabbarcontroller/menucontroller. Thta took like a day and have freed us from all the fixes and quirks.
My hack works, but I recommend building your own navigation class - it will pay off in the long run :-)
Custom Tab Bar Menu with horizontal swipe
You can use a UIScrollView
and add child viewcontrollers to it. I made an extension to UIViewController that easily allows you to create a swipe view.
extension UIViewController {
public func addViewControllerToContainer(viewController: UIViewController, count: CGFloat = 0, container: UIScrollView, heightDecrease: CGFloat = 0, startIndex: CGFloat = 0) {
let multiplier: CGFloat = count
addChildViewController(viewController)
container.addSubview(viewController.view)
container.contentSize.width += viewController.view.frame.width
container.contentSize.height = viewController.view.frame.height - heightDecrease
container.frame = CGRect(x: viewController.view.frame.origin.x, y: viewController.view.frame.origin.y, width: viewController.view.frame.width, height: viewController.view.frame.height - heightDecrease)
container.frame.origin.y += heightDecrease
container.contentOffset.x = container.frame.width * startIndex
viewController.view.frame.size.width = container.frame.width
viewController.view.frame.size.height = container.frame.height
viewController.view.frame.size.height -= heightDecrease
viewController.view.frame.origin.x = container.frame.width * multiplier
}
public func addViewControllersToContainer(viewControllers: [UIViewController], container: UIScrollView, heightDecrease: CGFloat = 0, startIndex: CGFloat) {
var count: CGFloat = 0
for viewController in viewControllers {
addViewControllerToContainer(viewController: viewController, count: count, container: container, heightDecrease: heightDecrease, startIndex: startIndex)
count += 1
}
}
}
class MainSwipeViewController: UIViewController {
let viewControllers: [UIViewController] = [VC1, VC2, VC3] // view controllers swiped between
let startIndex: CGFloat = 0 // which viewController to begin at (0 means first)
let mainScrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.backgroundColor = .lightGray
scrollView.isPagingEnabled = true
scrollView.showsHorizontalScrollIndicator = false
scrollView.bounces = false
scrollView.contentInsetAdjustmentBehavior = .never
scrollView.backgroundColor = UIColor.clear
return scrollView
}()
private func addViewControllers(_ vc: UIViewController, viewControllers: [UIViewController], startIndex: CGFloat = 0) {
view.addSubview(mainScrollView)
addViewControllersToContainer(viewControllers: viewControllers, container: mainScrollView, startIndex: startIndex)
}
override func viewDidLoad() {
super.viewDidLoad()
addViewControllers(self, viewControllers: viewControllers, startIndex: startIndex)
}
}
As for the tabbar menu, you can easily create that by implementing UIScrollViewDelegate
in MainSwipeViewController
extension MainSwipeViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let contentOffset = scrollView.contentOffset.x / view.frame.width
}
}
contentOffset
is the interval of your swipe and increases by one everytime you swipe. This will help you animate the blue bar in your menu.
Related Topics
Uigesturerecognizer and Uitableviewcell Issue
Customizing the More Menu on a Tab Bar
How to Know If Two Emojis Will Be Displayed as One Emoji
How Can a Web Application Send Push Notifications to iOS Devices
Does H.264 Encoded Video with Bt.709 Matrix Include Any Gamma Adjustment
How to Resize Uiimageview Based on Uiimage's Size/Ratio in Swift 3
Wait Until Multiple Networking Requests Have All Executed - Including Their Completion Blocks
Replacement for C-Style Loop in Swift 2.2
How to Fix "No Valid 'Aps-Environment' Entitlement String Found for Application" in Xcode 4.3
Emulating Aspect-Fit Behaviour Using Autolayout Constraints in Xcode 6
Presentviewcontroller:Animated:Yes View Will Not Appear Until User Taps Again
iOS How to Set App Icon and Launch Images
How to Load a Xib File in a Uiview
Swift Compiler Shows Expected Declaration Error
Uibutton Image Behavior Changed in iOS 15
Behaviour for Significant Change Location API When Terminated/Suspended