AdMob iOS-更改背景颜色

时间:2019-03-28 09:44:49

标签: ios objective-c xcode admob banner

我正在使用AdMob在我的应用中展示广告。我将广告设置为“智能横幅” ...看起来一切正常,但是我的问题是横幅必须适应新尺寸时黑色的填充空间...

enter image description here

有没有办法用其他颜色覆盖这些黑色空间?

这是我的实现方式

- (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]
                                              ]];


}

0 个答案:

没有答案