项目作者: blog-razrabotchika

项目描述 :
Simple tableview cell/header/footer with AdMob banner.
高级语言: Swift
项目地址: git://github.com/blog-razrabotchika/GoogleMobileAdsCell.git
创建时间: 2020-05-01T08:38:36Z
项目社区:https://github.com/blog-razrabotchika/GoogleMobileAdsCell

开源协议:

下载


GoogleMobileAdsCell

Usage as section header:

```swift
let bannerViewHeight = GADBannerView(adSize: kGADAdSizeBanner).frame.size.height

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return bannerViewHeight + 15
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

  1. let cell = AdCell(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: bannerViewHeight))
  2. let bannerView = AdCell.cellBannerView(rootVC: self, frame:cell.bounds)
  3. bannerView.translatesAutoresizingMaskIntoConstraints = false
  4. cell.addSubview(bannerView)
  5. bannerView.centerXAnchor.constraint(equalTo: cell.centerXAnchor).isActive = true
  6. bannerView.centerYAnchor.constraint(equalTo: cell.centerYAnchor, constant: -3).isActive = true
  7. let request = GADRequest()
  8. bannerView.load(request)
  9. return cell
  10. }