如何让AdMob成为最佳人选?

时间:2016-05-09 05:22:47

标签: ios swift admob

我对AdMob有疑问,

我希望将其作为自动布局

看图片

enter image description here

 Banner = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
        Banner.adUnitID = "*********"
        Banner.rootViewController = self
        let req: GADRequest = GADRequest()
        Banner.loadRequest(req)
        Banner.frame = CGRectMake(0, view.bounds.height - Banner.frame.size.height, Banner.frame.size.width, Banner.frame.size.height)
        self.view.addSubview(Banner)

enter image description here

2 个答案:

答案 0 :(得分:1)

    Banner.frame = CGRectMake(0, 0, Banner.frame.size.width, Banner.frame.size.height)
    self.view.addSubview(Banner)
    self.view.sendSubviewToBack(Banner)

答案 1 :(得分:1)

更改此

    self.view.addSubview(Banner)

进入

      navigationBar.addSubview(Banner)

或使用

   self.navigationController!.navigationBar.addSubview(Banner)

有关其他信息,请参阅this

<强>更新

更改Banner的框架,因为它占据了导航栏的整个宽度。更改XWidth并尝试举例

Banner.frame = CGRectMake(50, 0, Banner.frame.size.width - 50, Banner.frame.size.height)