我对AdMob有疑问,
我希望将其作为自动布局
看图片
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)
答案 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
的框架,因为它占据了导航栏的整个宽度。更改X
和Width
并尝试举例
Banner.frame = CGRectMake(50, 0, Banner.frame.size.width - 50, Banner.frame.size.height)