swift – iOS TabMan Customized Tab Bar. I need topBarContainer addArrangeSubView

swift – iOS TabMan Customized Tab Bar. I need topBarContainer addArrangeSubView


I need Customized Tab Bar,
however container PageViewController’s SafeArea is Not StackView.bottomAnchor.
PageViewController’s SafeArea is view.safeLayoutGuide.topAnchor

I need TabManViewContorller’s topBarContainer.addArrangeSubviews, however It is inner so I am unable to.

How Can I do that like second Image ?

class ButtonBarExampleViewController: TabmanViewController, PageboyViewControllerDataSource, TMBarDataSource {

    // MARK: Properties
    non-public let stackView: UIStackView = {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.backgroundColor = .crimson
        stackView.translatesAutoresizingMaskIntoConstraints = false
        return stackView
    }()
    
    non-public let imageView: UIImageView = {
        let imageView = UIImageView()
        imageView.backgroundColor = .inexperienced
        return imageView
    }()
    
    non-public let tempView = UIView()
    
    
    /// View controllers that can be displayed in web page view controller.
    non-public lazy var viewControllers: [UIViewController] = [
        ChildViewController(page: 1),
        ChildViewController(page: 2),
        ChildViewController(page: 3),
        ChildViewController(page: 4),
        ChildViewController(page: 5)
    ]
    
    // MARK: Lifecycle
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        
        // Set PageboyViewControllerDataSource dataSource to configure web page view controller.
        dataSource = self
        
        // Create a bar
        let bar = TMBarView.ButtonBar()
       ...
        
        // Add bar to the view - as a .systemBar() so as to add UIKit fashion system background views.
//        addBar(bar.systemBar(), dataSource: self, at: .prime)
        addBar(bar, dataSource: self, at: .customized(view: tempView, structure: nil))
        view.addSubview(stackView)
        NSLayoutConstraint.activate([
            stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            imageView.heightAnchor.constraint(equalToConstant: 60)
        ])
        stackView.addArrangedSubview(imageView)
        stackView.addArrangedSubview(tempView)

    }
    
}

enter image description here

enter image description here

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.