9.5 C
New York
Tuesday, March 11, 2025

ios – UITabBarController Head and Physique Structure


Possibly there is not a means. I am fairly certain there’s a method to customise the UITabBarController format to work.

My query is about having a header and physique in UITabBarController. I’ve the next code within the TabBarLayout.

import UIKit

class TabBarLayout: UITabBarController {
  
  @IBOutlet var viewHeader: UIView!

  override func viewDidLoad() {
    tremendous.viewDidLoad()
    viewHeader.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(viewHeader)
    let leftSide = NSLayoutConstraint(merchandise: viewHeader!, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, fixed: 0.0)
    let rightSide = NSLayoutConstraint(merchandise: viewHeader!, attribute: .proper, relatedBy: .equal, toItem: view, attribute: .proper, multiplier: 1.0, fixed: 0.0)
    let topSide = NSLayoutConstraint(merchandise: viewHeader!, attribute: .high, relatedBy: .equal, toItem: view, attribute: .high, multiplier: 1.0, fixed: 0.0)
    let peak = NSLayoutConstraint(merchandise: viewHeader!, attribute: .peak, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, fixed: 100)
    view.addConstraint(leftSide)
    view.addConstraint(rightSide)
    view.addConstraint(topSide)
    view.addConstraint(peak)
  }
}

The Storyboard has UITabBarController with Storyboard References.

UITabBarController Layout

The Purchase Storyboard exhibits the next screenshot:

Buy Storyboard

import UIKit

class BuyController: UIViewController {
  
  override func viewWillAppear(_ animated: Bool) {
    tremendous.viewWillAppear(animated)
    print("BUYCONTROLLER")
    let tbc = tabBarController as! TabBarLayout
    
    // How do I align this view's topAnchor to viewHeader's backside anchor?
  }
}

How ought to I align the Purchase Storyboard high anchor to viewHeader’s backside anchor in order that the Check Label is seen?

iOS Simulator

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles