Reputation: 2051
I created a 320x50 banner ad using this code:
var bannerView = GADBannerView(frame:CGRectMake(0, 20, 320, 50))
The ad should have y-position of 20 to leave a space for the status bar. Now, I would like to change to using a Smart Banner. So I changed my code to:
let bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
Obviously the above code covers the status bar. I have no idea on how to make the Smart Banner appear at a y-position of 20.
Upvotes: 2
Views: 1834
Reputation: 18878
Change your bannerView
's frame
:
let bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
bannerView.frame = CGRect(x: 0.0,
y: UIApplication.sharedApplication().statusBarFrame.size.height,
width: bannerView.frame.width,
height: bannerView.frame.height)
Also, setting static positions is usually never a good idea. You can get the status bar's height with UIApplication.sharedApplication().statusBarFrame.size.height
. This way, if the status bar height ever changes you don't have to worry about it.
Upvotes: 3
Reputation: 705
You can initiate the view as below:
let bannerView = GADBannerView(frame:CGRectMake(0, UIApplication.sharedApplication().statusBarFrame.size.height, CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).width, CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height))
Upvotes: 2
Reputation: 131
You can change your bannerview's frame like this:
bannerView.frame = CGRectMake(0, 20, bannerView.frame.width, bannerView.frame.height)
Upvotes: 0