Reputation: 35
Is it possible to put admit banner in the middle of navigationController.toolbar
? Way I did it (inside viewDidLoad
):
let banner = GADBannerView(adSize: kGADAdSizeBanner)
banner.adUnitID="ca-app-pub-123"
banner.rootViewController=self
banner.load(GADRequest())
self.navigationController?.isToolbarHidden=false
self.navigationController?.toolbar.addSubview(banner)
self.navigationController?.toolbar.sizeToFit()
However banner is aligned to the left side of a toolbar. Is there a simple way to align banner to the middle?
Upvotes: 0
Views: 259
Reputation: 1633
Please add position for your banner
banner.frame.origin = CGPoint(x: self.navigationController?.toolbar.frame.width / 2 - banner.frame.width / 2, y: self.navigationController?.toolbar.frame.height / 2 - banner.frame.height / 2)
Upvotes: 1