0

재료 디자인 라이브러리를 iOS에서 사용하고 있습니다. 내비게이션 막대 아래의 사용자 정의보기에 MDCTabBar을 추가하려고하는데 작동하지 않습니다. 여기MDCTabBar를 사용자 정의보기에 추가하는 방법은 무엇입니까?

let tabBar = MDCTabBar(frame: self.mainTabBar.bounds) 
    tabBar.items = [ 
     UITabBarItem(title: "TAB 1", image: nil, tag: 0), 
     UITabBarItem(title: "TAB 2", image: nil, tag: 1), 
    ] 
    tabBar.tintColor = UIColor.white 
    tabBar.barTintColor = UIColor.theme 
    tabBar.alignment = .justified 
    tabBar.itemAppearance = .titles 
    tabBar.autoresizingMask = [.flexibleWidth, .flexibleTopMargin] 
    tabBar.displaysUppercaseTitles = true 
    tabBar.sizeToFit() 
    self.mainTabBar.addSubview(tabBar) 

mainTabBar 내 사용자 정의보기이며 정확하게 탐색 모음 아래처럼 코드입니다. 이 문제를 해결하는 데 도움주세요.

미리 감사드립니다.

답변

1
let tabBar = MDCTabBar(frame: self.mainTabBar.bounds) 
tabBar.delegate = self 
tabBar.items = [ 
     UITabBarItem(title: "Tab 1", image: nil, tag: 0), 
     UITabBarItem(title: "Tab 2", image: nil, tag: 1), 
    ] 
tabBar.tintColor = UIColor.white 
tabBar.barTintColor = UIColor.theme 
tabBar.alignment = .justified 
tabBar.itemAppearance = .titles 
tabBar.autoresizingMask = [.flexibleWidth, .flexibleTopMargin] 
tabBar.displaysUppercaseTitles = true 
tabBar.sizeToFit() 
self.mainTabBar.addSubview(tabBar) 

mainTabBar에 MDCTabBar 클래스를 스토리 보드에있는 UIView를 끌어 선택할 수 있습니다 정확히 내비게이션 바 아래에 내있는 CustomView이다.

0

귀하의 ViewController 클래스는 같은 MDCTabBarViewController 클래스에서 상속 할 수 있습니다

class SelectTeamViewController: MDCTabBarViewController { 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     // Do any additional setup after loading the view. 
    } 
} 

는 그럼 볼 수 있어야합니다. 당신도 신원 경위 여기