试试这个添加见:
请按照以下步骤实现它:
UIViewController在情节提要的根目录中添加Container View进去UIViewControllerAdView在下面添加Container viewUITabbarController与Container view我能够在我的 UITabBarController 中创建一个 UIView
lazy var bannerAd: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .black
return view
}()
Run Code Online (Sandbox Code Playgroud)
然后将其固定在底部,如下所示:
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
Run Code Online (Sandbox Code Playgroud)
然后为了向上移动标签栏,我这样做了:
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
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4130 次 |
| 最近记录: |