Xlpagertabstrip: How to add headerview of ButtonBarPagerTabStripViewController programming?

Created on 30 Jan 2018  路  9Comments  路  Source: xmartlabs/XLPagerTabStrip

I want XLPagerTabStrip under my customized view like following image.
How to achieve this view?
Thanks.

img_1622_opt

Most helpful comment

don't work correctly...

Alternatively You can simply use something like this after super.viewDidLoad():

// Remove TabBarView and ContainerView from Superview
buttonBarView.removeFromSuperview()
containerView.removeFromSuperview()

// Add your HeaderView and put back TabBarView and ContainerView
view.addSubview(headerView)
view.addSubview(buttonBarView)
view.addSubview(containerView)

// Setup frames
headerView.frame = CGRect(
    x: 0,
    y: 0,
    width: self.view.bounds.width,
    height: 100.0)

buttonBarView.frame = CGRect(
    x: 0,
    y: headerView.frame.height,
    width: self.view.bounds.width,
    height: 50.0)

containerView.frame = CGRect(
    x: 0,
    y: headerView.frame.height + buttonBarView.frame.height,
    width: self.view.bounds.width,
    height: self.view.bounds.height - (headerView.frame.height + buttonBarView.frame.height))

1) TabBarView and ContainerView were removed and put back to Superview
2) TabBarView and ContainerView were not removed from Superview

simulator screen shot - iphone 6 plus - 2019-02-26 at 03 47 01 simulator screen shot - iphone 6 plus - 2019-02-26 at 03 48 57

All 9 comments

I also want to know

Yeah, me too

Me too

I also need this

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        buttonBarView.frame = CGRect(
            x: 0,
            y: headerView.frame.height,
            width: self.view.bounds.width,
            height: 50.0)
}
override func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()
      buttonBarView.frame = CGRect(
          x: 0,
          y: headerView.frame.height,
          width: self.view.bounds.width,
          height: 50.0)
}

don't work correctly...

What kind of problem do you have with the code?

don't work correctly...

Alternatively You can simply use something like this after super.viewDidLoad():

// Remove TabBarView and ContainerView from Superview
buttonBarView.removeFromSuperview()
containerView.removeFromSuperview()

// Add your HeaderView and put back TabBarView and ContainerView
view.addSubview(headerView)
view.addSubview(buttonBarView)
view.addSubview(containerView)

// Setup frames
headerView.frame = CGRect(
    x: 0,
    y: 0,
    width: self.view.bounds.width,
    height: 100.0)

buttonBarView.frame = CGRect(
    x: 0,
    y: headerView.frame.height,
    width: self.view.bounds.width,
    height: 50.0)

containerView.frame = CGRect(
    x: 0,
    y: headerView.frame.height + buttonBarView.frame.height,
    width: self.view.bounds.width,
    height: self.view.bounds.height - (headerView.frame.height + buttonBarView.frame.height))

1) TabBarView and ContainerView were removed and put back to Superview
2) TabBarView and ContainerView were not removed from Superview

simulator screen shot - iphone 6 plus - 2019-02-26 at 03 47 01 simulator screen shot - iphone 6 plus - 2019-02-26 at 03 48 57

don't work correctly...

Alternatively You can simply use something like this after super.viewDidLoad():

// Remove TabBarView and ContainerView from Superview
buttonBarView.removeFromSuperview()
containerView.removeFromSuperview()

// Add your HeaderView and put back TabBarView and ContainerView
view.addSubview(headerView)
view.addSubview(buttonBarView)
view.addSubview(containerView)

// Setup frames
headerView.frame = CGRect(
  x: 0,
  y: 0,
  width: self.view.bounds.width,
  height: 100.0)

buttonBarView.frame = CGRect(
  x: 0,
  y: headerView.frame.height,
  width: self.view.bounds.width,
  height: 50.0)

containerView.frame = CGRect(
  x: 0,
  y: headerView.frame.height + buttonBarView.frame.height,
  width: self.view.bounds.width,
  height: self.view.bounds.height - (headerView.frame.height + buttonBarView.frame.height))
1. TabBarView and ContainerView were removed and put back to Superview

2. TabBarView and ContainerView were not removed from Superview

simulator screen shot - iphone 6 plus - 2019-02-26 at 03 47 01 simulator screen shot - iphone 6 plus - 2019-02-26 at 03 48 57

Yep. this work correctly!
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewabdalla picture andrewabdalla  路  6Comments

nikhil191090 picture nikhil191090  路  5Comments

Mohammed-Eliass picture Mohammed-Eliass  路  4Comments

unittesting0 picture unittesting0  路  3Comments

dkononenko picture dkononenko  路  4Comments