Browse Source

BaseButtonBar: position ButtonBar correctly

Carola Nitz 7 years ago
parent
commit
b24eb3c4de
1 changed files with 9 additions and 23 deletions
  1. 9 23
      Sources/BaseButtonBarPagerTabStripViewController.swift

+ 9 - 23
Sources/BaseButtonBarPagerTabStripViewController.swift

@@ -199,29 +199,23 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType: UICollect
         let buttonBarViewAux = buttonBarView ?? {
         let buttonBarViewAux = buttonBarView ?? {
             let flowLayout = UICollectionViewFlowLayout()
             let flowLayout = UICollectionViewFlowLayout()
             flowLayout.scrollDirection = .horizontal
             flowLayout.scrollDirection = .horizontal
-//            let buttonBarHeight:CGFloat = 34.0
-//            let yPos: CGFloat;
-//            if #available(iOS 11.0, *) {
-//                yPos = navigationController!.navigationBar.safeAreaInsets.top + navigationController!.navigationBar.frame.height
-//            } else {
-//                yPos = navigationController!.navigationBar.frame.maxY
-//            }
             let buttonBar = ButtonBarView(frame: .zero, collectionViewLayout: flowLayout)
             let buttonBar = ButtonBarView(frame: .zero, collectionViewLayout: flowLayout)
             buttonBar.backgroundColor = .orange
             buttonBar.backgroundColor = .orange
             buttonBar.selectedBar.backgroundColor = .black
             buttonBar.selectedBar.backgroundColor = .black
-            buttonBar.autoresizingMask = .flexibleWidth
-//            var newContainerViewFrame = containerView.frame
-//            newContainerViewFrame.origin.y = buttonBar.frame.maxY
-//            newContainerViewFrame.size.height = containerView.frame.size.height - (buttonBar.frame.maxY - containerView.frame.origin.y)
-//            containerView.frame = newContainerViewFrame
             return buttonBar
             return buttonBar
             }()
             }()
         buttonBarView = buttonBarViewAux
         buttonBarView = buttonBarViewAux
 
 
         if buttonBarView.superview == nil {
         if buttonBarView.superview == nil {
-            buttonBarView.translates
+            buttonBarView.translatesAutoresizingMaskIntoConstraints = false
             view.addSubview(buttonBarView)
             view.addSubview(buttonBarView)
-            NSlAyou
+            NSLayoutConstraint.activate([
+                buttonBarView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor),
+                buttonBarView.rightAnchor.constraint(equalTo: view.rightAnchor),
+                buttonBarView.leftAnchor.constraint(equalTo: view.leftAnchor),
+                buttonBarView.heightAnchor.constraint(equalToConstant: 35)
+                ]
+            )
         }
         }
         if buttonBarView.delegate == nil {
         if buttonBarView.delegate == nil {
             buttonBarView.delegate = self
             buttonBarView.delegate = self
@@ -285,18 +279,10 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType: UICollect
     open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
     open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
         super.viewWillTransition(to: size, with: coordinator)
     }
     }
+    
     open override func updateContent() {
     open override func updateContent() {
         super.updateContent()
         super.updateContent()
-//        let yPos: CGFloat;
-//        if #available(iOS 11.0, *) {
-//            yPos = navigationController!.navigationBar.safeAreaInsets.top + navigationController!.navigationBar.frame.height
-//        } else {
-//            yPos = navigationController!.navigationBar.frame.maxY
-//        }
-        buttonBarView.frame = CGRect(x: CGFloat(0), y: 150
-            - buttonBarView.frame.height, width: view.frame.width, height: buttonBarView.frame.height)
     }
     }
-
     // MARK: - Public Methods
     // MARK: - Public Methods
 
 
     open override func reloadPagerTabStripView() {
     open override func reloadPagerTabStripView() {