Closed SirSamShaw closed 7 years ago
@SirSamShaw Yeah definitely, though not out of the box. you'll have to make some modifications to the constraints in the loadView
function. I'll update this issue with the modifications that are needed.
There you go:
Couple issues that I noticed with this solution:
override public func loadView() {
super.loadView()
//init primary views
self.controllersContainer = UIView()
self.buttonsContainer = UIView()
self.separatorLine = UIView()
let nbh = self.navigationController?.navigationBar.frame.height ?? 0
//add in correct hierachy
self.view.addSubview(self.controllersContainer)
self.view.addSubview(self.separatorLine)
self.view.addSubview(self.buttonsContainer)
//disable autoresizing mask
self.controllersContainer.translatesAutoresizingMaskIntoConstraints = false
self.buttonsContainer.translatesAutoresizingMaskIntoConstraints = false
self.separatorLine.translatesAutoresizingMaskIntoConstraints = false
//setup constraints
let margins = self.view!
self.buttonsContainer.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
self.buttonsContainer.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true
//self.buttonsContainer.topAnchor.constraint(equalTo: margins.topAnchor,constant: 64).isActive = true
self.buttonsContainer.topAnchor.constraint(equalTo: margins.topAnchor,constant: nbh > 0 ? nbh + 20 : 0 ).isActive = true
self.buttonsContainerHeightConstraint = self.buttonsContainer.heightAnchor.constraint(equalToConstant: 50)
self.buttonsContainerHeightConstraint.isActive = true
self.separatorLine.topAnchor.constraint(equalTo: self.buttonsContainer.bottomAnchor).isActive = true
self.separatorLine.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
self.separatorLine.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true
self.separatorLineHeightConstraint = separatorLine.heightAnchor.constraint(equalToConstant: 1)
self.separatorLineHeightConstraint.isActive = true
self.controllersContainer.topAnchor.constraint(equalTo: self.separatorLine.bottomAnchor).isActive = true
self.controllersContainer.bottomAnchor.constraint(equalTo: margins.bottomAnchor).isActive = true
self.controllersContainer.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
self.controllersContainer.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true
}
@SirSamShaw Was your problem solved?
Can I use this on top of my view like the youtube app?