Skip to content

Commit 9d9257e

Browse files
author
Artsem Lemiasheuski
committed
Using of adaptive banner.
1 parent 29a5aa1 commit 9d9257e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

OpenDocumentReader/DocumentViewController.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,24 @@ class DocumentViewController: UIViewController, DocumentDelegate {
6464

6565
document?.webview = self.webview
6666

67+
bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
68+
bannerView.rootViewController = self
69+
70+
loadBannerAd()
71+
}
72+
73+
func loadBannerAd() {
6774
if ConfigurationManager.manager.configuration == Constants.configurationLite {
68-
bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
69-
bannerView.rootViewController = self
75+
let frame = { () -> CGRect in
76+
if #available(iOS 11.0, *) {
77+
return view.frame.inset(by: view.safeAreaInsets)
78+
} else {
79+
return view.frame
80+
}
81+
}()
82+
let viewWidth = frame.size.width
83+
84+
bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)
7085
bannerView.load(GADRequest())
7186
} else {
7287
bannerView.isHidden = true

0 commit comments

Comments
 (0)