How to position banner ads over UITabbar?

风流意气都作罢 提交于 2019-12-04 14:39:19

问题


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!)


回答1:


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.



来源:https://stackoverflow.com/questions/32978393/how-to-position-banner-ads-over-uitabbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!