Ryan.H
Ryan.H

Reputation: 361

Swift: Layout issues for GADBannerView with different size classes

This question may be a duplicate but I cannot seem to find an answer for it.

I have a 320 x 50 GADBannerView centered at the bottom of the view controller. When loaded the bannerView changes size from the specified width: 320 & height: 50 which I have tried to override with the following code:

override func viewDidLayoutSubviews() {

    self.bannerView.frame = CGRect(x: view.frame.minX, y: view.frame.maxY, width: 320, height: 50)
    super.viewDidLayoutSubviews()
}

but this is causing the banner to load 1/3 of the way up the page on the iPhone 7 and 6, to load to the bottom righthand side of the viewcontroller on the iPhone 5s and SE, to not appear at all on the 6 & 7 plus and to appear off centre to the left on iPad models.

Constraints: enter image description here

I have tried using the vary for traits feature in Xcode 8 but this seems to set the constraints on every size class instead of the isolated size class.

Is there a way to get the GADBannerView a fixed width:320, height: 50 and centered at the bottom of the view controller for all sizes and models?

Upvotes: 3

Views: 406

Answers (0)

Related Questions