-0.4 C
New York
Saturday, February 22, 2025

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 can not.

How Can I do that like second Image ?

class ButtonBarExampleViewController: TabmanViewController, PageboyViewControllerDataSource, TMBarDataSource {

    // MARK: Properties
    personal let stackView: UIStackView = {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.backgroundColor = .purple
        stackView.translatesAutoresizingMaskIntoConstraints = false
        return stackView
    }()
    
    personal let imageView: UIImageView = {
        let imageView = UIImageView()
        imageView.backgroundColor = .inexperienced
        return imageView
    }()
    
    personal let tempView = UIView()
    
    
    /// View controllers that will probably be displayed in web page view controller.
    personal 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 model system background views.
//        addBar(bar.systemBar(), dataSource: self, at: .high)
        addBar(bar, dataSource: self, at: .customized(view: tempView, format: 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

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles