do it better
do it better

Reputation: 4807

How to position banner ads over UITabbar?

I want to use ads in my application. I added a tab bar as shown below. I would like the advertisement to appear right above the tab bar.

To do this I added the bannerView as a subview on the view that I created. However, it did not show the banner.

How would you create the structure show below?

googleBannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
        googleBannerView.adUnitID = "ca-app-pub-5378899862041789/8532100959"
        googleBannerView.rootViewController = self
        let request: GADRequest = GADRequest()
        googleBannerView.loadRequest(request)
        googleBannerView.frame = CGRectMake(0, adBannerView.layer.frame.minY, googleBannerView.frame.size.width, googleBannerView.frame.size.height)
        //googleBannerView.frame = adBannerView.frame
        adBannerView.addSubview(googleBannerView!)

enter image description here

Upvotes: 1

Views: 3152

Answers (1)

do it better
do it better

Reputation: 4807

I solved the problem by positioning the ad with CGRectMake().

googleBannerView.frame = CGRectMake(0, (view.bounds.height - googleBannerView.frame.size.height) - 49, self.view.bounds.size.width, 49)

49 is the height of UITabBar.

Upvotes: 3

Related Questions