How to remove white background from MobFox ad on iPhone?

162 Views Asked by At

When adding a MobFox advertisement to my view with dimensions of 320x50, it displays white colored sidebars when the supplied ad has 300x50 dimensions.

It turns out that the background color of the View is white, regardless of what value I supply in the IB editor. Also setting the background color of the MobFoxBannerView does not solve the problem.

// mobFoxView is a MobFoxBannerView loaded from a NIB
// The following line will NOT result in a transparent background. It remains white!
[mobFoxView setBackgroundColor:[UIColor clearColor]];
1

There are 1 best solutions below

1
On

It turns out that the MobFoxBannerView contains a UIWebView subview, not accessible through the SDK API. UIWebViews will have a white background by default. Just added the following code to have a transparent background. Make sure this code is called after the view is actually loaded into memory.

- (void) makeMobFoxViewTransparent:(MobFoxBannerView *)mobFoxView 
{
    [[mobFoxView subviews] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        if ( [obj isKindOfClass:[UIWebView class]] )
        {
            UIWebView  *theSubView = (UIWebView *) obj;            
            theSubView.opaque = NO;
            [theSubView setBackgroundColor:[UIColor clearColor]];
        }
    }];
}