如何在UITabbar上放置横幅广告? [英] How to position banner ads over UITabbar?
本文介绍了如何在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.
为此,我添加了 bannerView
作为我创建的视图上的子视图。但是,它没有显示横幅。
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!)
推荐答案
我通过将广告定位在CGRe ctMake()。
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是高度UITabBar。
49 is the height of UITabBar.
这篇关于如何在UITabbar上放置横幅广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文