I am trying to see how i can add a UIView under my UITabBarController so i can add ads to my app, I cant seem to figure out any way to constrain my UIView to the bottom of the tab bar. Is this possible?
EDIT: By bottom of the tab bar i mean below the tab bar
I was able to create a UIView in my UITabBarController
lazy var bannerAd: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .black
return view
}()
And then pin it to the bottom like so:
view.addSubview(bannerAd)
bannerAd.heightAnchor.constraint(equalToConstant: 44).isActive = true
bannerAd.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
bannerAd.widthAnchor.constraint(equalTo: self.view.widthAnchor).isActive = true
then to move up the Tab Bar i did so like this:
override func viewWillLayoutSubviews() {
if !didStyleTabBar {
self.tabBar.invalidateIntrinsicContentSize()
var tabFrame = self.tabBar.frame
tabFrame.size.height = tabBarHeight
tabFrame.origin.y = tabFrame.origin.y - 44
self.tabBar.frame = tabFrame
didStyleTabBar = true
}
}