cosbyPlays
cosbyPlays

Reputation: 21

AdMob ad banner not changing position (Swift 3)

Hi there I'm trying to change the position of my AdMob banner in one of my scenes. The ad displays successfully (and is hidden successfully) whenever I set it to be, but it doesn't take the position I give it. It's always on the top. How can I set it to position at the bottom of the screen?

    banner.frame = CGRect(x:0.0,
                          y:-(self.view?.frame.size.height)! + banner.frame.size.height,
                          width:banner.frame.size.width,
                          height:banner.frame.size.height)

    banner = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
    banner.adUnitID = "ca-app-pub-xxxx"

    banner.rootViewController = gameViewController

    let request: GADRequest = GADRequest()
    request.testDevices = ["xxxx"]
    banner.load(request)

    self.view?.addSubview(banner)

Upvotes: 0

Views: 297

Answers (1)

user3078856
user3078856

Reputation:

You are initialising a new banner after setting the frame, switch lines 1 and 2 around.

Upvotes: 1

Related Questions