eggswift / ESTabBarController

:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie!
MIT License
5.17k stars 578 forks source link

Back button shown with a 10px offsetY. Happens both on iPhone6s and iPadPro #170

Closed neoneye closed 5 years ago

neoneye commented 5 years ago

Environment

iPhone6S, running iOS12.1 (16B92) iPadPro, running iOS12.0.1 (14A404) Xcode 10.1 (10B61) ESTabBarController, master branch commit 6510afbdfe23e18d7cf483a683e3f76f4069f8d2

Steps to reproduce

Step A: 1.4 UITabBarController style with 'More'

Step B: Tap the '...' More tabbaritem.

Step C: Now on the 'More' view controller. Tap the 'Me' row.

Step D: Now on the 'Me' page. BOOM: The back button is hanging 10pixels below where it's usually shown.

Idea for fix

Move the back button up 10pixels, so it's shown at the usual position.

Screenshot iPhone

img_3183

Screenshot iPadPro splitscreen

img_75874c76924f-1

benzamin commented 5 years ago

In the ExampleNavigationController.swift, you see these 2 lines are used to make the "back" text go away:

let appearance = UIBarButtonItem.appearance()
appearance.setBackButtonTitlePositionAdjustment(UIOffset.init(horizontal: 0.0, vertical: -60), for: .default)

Which actually off-centering the back button arrow. You should comment them, and add a new overridden method at the end of the ExampleNavigationController.swift file as following:

override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        self.visibleViewController?.navigationItem.backBarButtonItem = UIBarButtonItem.init(title: " ", style: .plain, target: nil, action: nil)
        super.pushViewController(viewController, animated: animated)
    }

Which will replace the "back" text to a space, and the purpose is served.

Thanks.

eggswift commented 5 years ago

@neoneye It's a very good question. Thanks for that. For this question, you can custom your own navigation controller in your project. In my example, it main job is show the ability of ESTabBarController on how to custom tab bar freedomlly :)