Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skparticles/d0cff5b1495c2701fab4c71bed5e7fe4 to your computer and use it in GitHub Desktop.
Save skparticles/d0cff5b1495c2701fab4c71bed5e7fe4 to your computer and use it in GitHub Desktop.
// Replace this to show / remove banner in BB3 Game.
-(void)showBanner{
UIView *view = [UIApplication sharedApplication].keyWindow.rootViewController.view;
if(!self.bannerView)
{
self.bottomLayoutGuide = [UIApplication sharedApplication].keyWindow.rootViewController.bottomLayoutGuide;
self.bannerView = [[GADBannerView alloc]
initWithAdSize:kGADAdSizeBanner];
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
[view addConstraints:@[
[NSLayoutConstraint constraintWithItem:self.bannerView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.bottomLayoutGuide
attribute:NSLayoutAttributeTop
multiplier:1
constant:0],
[NSLayoutConstraint constraintWithItem:self.bannerView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:view
attribute:NSLayoutAttributeCenterX
multiplier:1
constant:0]
]];
self.bannerView.adUnitID = BANNER_LIVE_ID;
self.bannerView.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[self.bannerView loadRequest:[GADRequest request]];
[view addSubview:self.bannerView];
}
[self.bannerView setHidden:NO];
}
-(void)hideBanner{
NSLog(@"[Ads] hide banner");
if(self.bannerView)
[self.bannerView setHidden:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment