AdMob iOS - Change background Color
Asked Answered
T

0

7

I'm using AdMob to display ads in my app. I implemented my ads as "Smart Banner" ... Everything seems to be working fine but my problem is the black fill spaces that the banner has when it has to adapt to the new dimensions ...

enter image description here

Is there a way to cover these black spaces with another color?

This is my implementation

- (void)viewDidLoad {
    [super viewDidLoad];

    _banner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
    _banner.translatesAutoresizingMaskIntoConstraints = NO;
    _banner.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
    _banner.rootViewController = self;
    [_banner loadRequest:[GADRequest request]];

    [self.view addSubview:_banner];

    UILayoutGuide *guide = self.view.safeAreaLayoutGuide;

    [NSLayoutConstraint activateConstraints:@[
                                              [guide.leftAnchor constraintEqualToAnchor:_banner.leftAnchor],
                                              [guide.rightAnchor constraintEqualToAnchor:_banner.rightAnchor],
                                              [guide.bottomAnchor constraintEqualToAnchor:_banner.bottomAnchor]
                                              ]];


}
Tasia answered 28/3, 2019 at 9:44 Comment(8)
you need to set _banner background color whatever you want before adding as a Subview.Rink
@NikunjKumbhani I tried but the black sides are not changed ...Tasia
set background color to clear color or white color and after that not changed then you need to set the smart banner size.Rink
@NikunjKumbhani I'm trying to follow your suggestion but I still don't get any change ... can you give me an example about my code that I entered in my application? maybe I'm wrongTasia
Try this https://mcmap.net/q/1629436/-set-admob-banner-to-appear-at-bottom-of-screenRink
@NikunjKumbhani I tried in every way ... even following the link that you kindly advised me .. but nothing ... continue to remain the black sides that google has insertedTasia
Let us continue this discussion in chat.Rink
Did you come up with any solution?Joslin

© 2022 - 2024 — McMap. All rights reserved.