Minitour / AZTabBarController

A custom tab bar controller for iOS written in Swift 4.2
MIT License
348 stars 65 forks source link

Controls are blocked by AZTabBarController.controller.view #61

Closed wilz05 closed 5 years ago

wilz05 commented 5 years ago

I'm trying to load AZTabBarController one ViewController, here is my code in viewdidload function `var icons = [UIImage]() icons.append(UIImage(named: "calendarfilter")! ) tabController = .insert(into: self, withTabIcons: icons) tabController.delegate = self let color = UIColor(red: 14.0/255, green: 122.0/255, blue: 254.0/255, alpha: 1.0) tabController.selectedColor = color tabController.highlightColor = color tabController.highlightedBackgroundColor = #colorLiteral(red: 0.1803921569, green: 0.8, blue: 0.4431372549, alpha: 1) tabController.defaultColor = .lightGray

    tabController.buttonsBackgroundColor = UIColor(red: (247.0/255), green: (247.0/255), blue: (247.0/255), alpha: 1.0)
    tabController.selectionIndicatorHeight = 0
    tabController.selectionIndicatorColor = color
    tabController.tabBarHeight = 60
    tabController.notificationBadgeAppearance.backgroundColor = .red
    tabController.notificationBadgeAppearance.textColor = .white
    tabController.notificationBadgeAppearance.borderColor = .clear
    tabController.notificationBadgeAppearance.borderWidth = 0.2
    tabController.setBadgeText("!", atIndex: 0)
    tabController.setAction(atIndex: 0){
         print(1)
    }
    tabController.animateTabChange = true
    tabController.onlyShowTextForSelectedButtons = false
    tabController.setTitle("Home", atIndex: 0)
    tabController.font = UIFont(name: "AvenirNext-Regular", size: 12)
     let container = tabController.buttonsContainer
    container?.layer.shadowOffset = CGSize(width: 0, height: -2)
    container?.layer.shadowRadius = 10
    container?.layer.shadowOpacity = 0.1
    container?.layer.shadowColor = UIColor.black.cgColor
    tabController.setButtonTintColor(color: #colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1), atIndex: 0)`

Added backgound color to identify the issue

open class func insert(into parent:UIViewController, withTabIcons icons: [UIImage],andSelectedIcons sIcons: [UIImage]? = nil)->AZTabBarController { let controller = AZTabBarController(withTabIcons: icons,highlightedIcons: sIcons) parent.addChild(controller) parent.view.addSubview(controller.view) print(parent.view.bounds) controller.view.backgroundColor = UIColor.flatLime() // added controller.view.frame = parent.view.bounds controller.didMove(toParent: parent) controller.currentTabBar?.present(parent, animated: true, completion: nil) return controller } Simulator Screen Shot - iPhone Xʀ - 2019-07-17 at 10 17 20

behind flatlime color(view) existing controls from viewcontroller exist but disabled coz of AZTabBarController.view How can I solve the above issue ? Or am I missing anything ?

Minitour commented 5 years ago

@wilz05 Hi, AZTabBarController is not a sub class of UITabBarController, and so you should not treat it as a native tab bar controller.

To add your child view controller to the tab bar simply call:

tabController.setViewController(myChildViewController, atIndex: 0)

Do not attempt to manually insert it to the controller. Hopefully this fixes your issue.

wilz05 commented 5 years ago

Added one empty UIViewController() tabController.setViewController(UIViewController(), atIndex: 0) It worked well, Thank you @Minitour