2

I have successfully implemented Carbon Kit scrollable TabBar with Images as icons. They problem I have is when I hit back. The icons will remain at the page for a while before disappearing. Is there a way to make them disappear immediately. If I hit the bottom tab bar. This thing will not happen. Please help

Video

enter image description here

Code

import UIKit
import CarbonKit

 class Result: UIViewController, CarbonTabSwipeNavigationDelegate {

    var sURL : String = ""

     override func viewDidLoad() {
    
        super.viewDidLoad()
    
        print( " From Home VC : ", sURL)
    
    //===== substring the URL to get the screen Name=============
        let startIndex = sURL.range(of: "result_")?.upperBound
        let startString = sURL.substring(from: startIndex!) //===startString:                   let endIndex = startString.range(of: ".")!.lowerBound //===endIndex: 
    
        var sScreen = startString.substring(to: endIndex)
    //=================================================================
    
    
        let iconNames = ["0mag", "1dmc", "2toto","3sg", "4lotto", "5cs", "6stc","7m101"]
        var images = [UIImage]()
    
        for icon in iconNames {
            if let img = UIImage(named: icon)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal) {
            images.append(img)
            }
        }
    
        let carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: images, delegate: self)
        //carbonTabSwipeNavigation.pagesScrollView?.isScrollEnabled = false
        carbonTabSwipeNavigation.insert(intoRootViewController: self)

        carbonTabSwipeNavigation.setTabExtraWidth(20)
        carbonTabSwipeNavigation.setTabBarHeight(100)
        carbonTabSwipeNavigation.toolbar.barTintColor = UIColor.black
        carbonTabSwipeNavigation.toolbar.isTranslucent=true
    
        var iIndex = UInt()
    
        if(sScreen=="mag"){
            iIndex = 0
        }else if(sScreen=="dmc"){
            iIndex = 1
        }else if(sScreen=="toto"){
            iIndex = 2
        }else if(sScreen=="sg"){
            iIndex = 3
        }else if(sScreen=="lotto"){
            iIndex = 4
        }else if(sScreen=="stc"){
            iIndex = 5
        }else if(sScreen=="cs"){
            iIndex = 6
        }else if(sScreen=="m101"){
            iIndex = 7
        }
   
        print("The iIndex: ", iIndex)
    
        carbonTabSwipeNavigation.setCurrentTabIndex(iIndex, withAnimation: true)
    
    }

    override func viewDidAppear(_ animated: Bool) {
    
        super.viewDidAppear(animated)
    }

    func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {

        var screen = UIViewController()
        print("What is the index: " , index)
    
        if (index == 0){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "magnum4D" ) as! Magnum4D
        
        }else if (index == 1){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "dmc" ) as! DMC
        
        }else if (index == 2){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "toto" ) as! Toto
    
        }else if (index == 3){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "sg" ) as! SG
        
        }else if (index == 4){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "lotto" ) as! Lotto
        }else if (index == 5){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "stc" ) as! STC
        
        }else if (index == 6){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "cs" ) as! CS
        
        }else if (index == 7){
        
            screen = self.storyboard?.instantiateViewController( withIdentifier: "m101" ) as! M101
        }
    
        print(" What screen is called ", screen)
        return screen

    }
 }
Community
  • 1
  • 1
Hanz Cheah
  • 761
  • 5
  • 15
  • 44

2 Answers2

1

Those are menu items that are currently outside the view its boundries. Therefore ‘view.clipToBounds = true’ should work.

You could also try setting/animating the alpha of the menu items to 0 when ‘viewWillDissapear’ is called.

Lloyd Keijzer
  • 1,229
  • 1
  • 12
  • 22
0

after this :

 carbonTabSwipeNavigation.insert(intoRootViewController: self)

insert below

carbonTabSwipeNavigation.carbonTabSwipeScrollView.clipsToBounds = true
Marwan Alqadi
  • 795
  • 8
  • 14