I need my banner ads to be drawn / filled across the entire width of the screen below.
My code works for devices with a width equal to either MOPUB_BANNER_SIZE.width or MOPUB_LEADERBOARD_SIZE.width But on other devices (iPhone 5/6 / etc. And some iPads) my only option is to center the banner. here is the code:
if(!_mopubBanner){ NSString* bannerID; const CGSize* bannerSize; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ bannerID = @"MopubBannerId"; bannerSize = &MOPUB_BANNER_SIZE; } else{ bannerID = @"MopubLeaderboardId"; bannerSize = &MOPUB_LEADERBOARD_SIZE; } _mopubBanner = [[MPAdView alloc] initWithAdUnitId:bannerID size:*bannerSize]; _mopubBanner.delegate = self; CGRect BannerFrameRect; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { BannerFrameRect = CGRectMake(([[UIScreen mainScreen] bounds].size.width - MOPUB_BANNER_SIZE.width) / 2, [[UIScreen mainScreen] bounds].size.height - MOPUB_BANNER_SIZE.height, MOPUB_BANNER_SIZE.width, MOPUB_BANNER_SIZE.height); } else { BannerFrameRect = CGRectMake(([[UIScreen mainScreen] bounds].size.width - MOPUB_LEADERBOARD_SIZE.width) / 2, [[UIScreen mainScreen] bounds].size.height - MOPUB_LEADERBOARD_SIZE.height, MOPUB_LEADERBOARD_SIZE.width, MOPUB_LEADERBOARD_SIZE.height); } _mopubBanner.frame = BannerFrameRect; }
I tried setting custom sizes for the BannerFrameRect, but the banner ad just adjusts in the upper left corner of the new frame. It does not scale.
is there any way to resize the ad?
Thank you
source share