<br />

> [!NOTE]
> **Note:** Native Styles use HTML and CSS that you configure in Google Ad Manager. If you're looking to render your own in-app ads using native objects, please see [Native Advanced](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/native/advanced.md.txt).

[Native style settings](https://support.google.com/admanager/answer/6366914)
enable Google Ad Manager to handle the rendering of your native ads based on native
styles you specify within the product. First, specify size and targeting.
Then add HTML, CSS, and JavaScript to define ads that are responsive
and produce a quality display across all screens. You don't need to do
any of the rendering; Ad Manager automatically applies the right native style
for the destination. Native styles are implemented just like banner ads,
using a `GAMBannerView`. They can be used with a fixed ad
size determined ahead of time, or a fluid ad size determined at runtime.

## Prerequisites

- Google Mobile Ads SDK version 7.14.0 or higher

This guide assumes some working knowledge of Google Mobile Ads SDK.
If you haven't already done so, consider running through our
[Get Started](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start.md.txt) guide.

## Fixed size

Native styles with a fixed size let you control the width and height
of the native ad.

To set a fixed size, follow these steps:

Set an ad size smaller than or equal to the device screen size.
To determine the maximum screen size on iOS 26 and later, use the
[`UIWindowScene.effectiveGeometry.coordinateSpace`](https://developer.apple.com/documentation/uikit/uiwindowscene/geometry/coordinatespace)
property. On iOS 18 and earlier, use the
[`UIWindowScene.coordinateSpace`](https://developer.apple.com/documentation/uikit/uiwindowscene/coordinatespace)
property.
For details about size constraints, see
[Troubleshoot unfilled impressions in Ad Manager](https://support.google.com/admanager/answer/1739296).


1. Create a line item in the Ad Manager UI and select one of the
   predefined sizes from the `Size` field dropdown.

2. In Interface Builder, set the width and height of the `GAMBannerView`
   to match the predefined size you selected in step 1. You can see a
   list of sizes and their corresponding `GADAdSize` constants in the [Banner
   size](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/banner#banner_size)
   section.

Implementing native styles with a fixed size is as simple as following
the instructions in [Your first banner
request](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start#your_first_banner_request),
but you gain the flexibility and control over the HTML, CSS, and JavaScript
to give your banner ad a native look and feel that's natural in your app.

## Fluid size

In some cases, a fixed size may not make sense. For example, you may
want the width of the ad to match your app's content, but need its height
to dynamically adjust to fit the ad's content. To handle this case,
you can specify `Fluid` as the ad size in the Ad Manager UI, which
designates that the size of the ad is determined at runtime in the app.
The SDK provides a special `GADAdSize` constant,
[`kGADAdSizeFluid`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Constants.md.txt#/c:@kGADAdSizeFluid),
to handle this case. The fluid ad size height is dynamically determined
based on the publisher defined width, allowing the
[`GAMBannerView`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GAMBannerView.md.txt),
to adjust its height to match that of the creative.

### Fluid request

Unlike other ad formats, the `kGADAdSizeFluid` ad size does not have
a predefined width, so make sure to explicitly set the banner's frame
width in your code or in Interface Builder. If a width is not specified,
the SDK by default sets the height of the banner based on the full
width of the device.

If you make a multisize request that includes `kGADAdSizeFluid`,
the ad returned is always placed inside a fluid container and
behave like a fluid ad. In the event that a non-fluid creative is
returned in this fluid container, the SDK centers the ad in the
container so that you don't have to modify the width constraint
each time a new ad is returned.

The implementation for making a single size and a multisize fluid
request is very similar; the only difference is for a multisize
request, you set the `validAdSizes` property to specify the ad
sizes that are valid for the ad request:

### Swift

```swift
bannerView.validAdSizes = [nsValue(for: AdSizeFluid), nsValue(for: AdSizeBanner)]
```

### Objective-C

```objective-c
_bannerView.validAdSizes = @[ NSValueFromGADAdSize(kGADAdSizeFluid),
                              NSValueFromGADAdSize(kGADAdSizeBanner) ];
```

Here's what the full implementation looks like in code:

### Swift

```swift
var bannerView: AdManagerBannerView!

override func viewDidLoad() {
super.viewDidLoad()
  // Create the GAMBannerView and set its width to a width that makes sense for your
  // app. In this example, the width is set to the width of the UIViewController's
  // root view.
  bannerView = AdManagerBannerView(adSize: AdSizeFluid)
  var frameRect = bannerView.frame
  frameRect.size.width = view.bounds.width
  bannerView.frame = frameRect

  // Uncomment this code for a multisize fluid request.
  // bannerView.validAdSizes = [nsValue(for: AdSizeFluid), nsValue(for: AdSizeBanner)]

  bannerView.adUnitID = "YOUR_AD_UNIT_ID"
  bannerView.rootViewController = self

  // Make the ad request.
  bannerView.load(AdManagerRequest())
}
```

### Objective-C

```objective-c
GAMBannerView *_bannerView;

- (void)viewDidLoad {
  [super viewDidLoad];
  // Create the GAMBannerView and set its width to a width that makes sense for your
  // app. In this example, the width is set to the width of the UIViewController's
  // root view.
  _bannerView = [[GAMBannerView alloc] initWithAdSize:kGADAdSizeFluid];
  CGRect frameRect = _bannerView.frame;
  frameRect.size.width = CGRectGetWidth(self.view.bounds);
  _bannerView.frame = frameRect;

  // Uncomment this code for a multisize fluid request.
  // _bannerView.validAdSizes = @[ NSValueFromGADAdSize(kGADAdSizeFluid),
  //                               NSValueFromGADAdSize(kGADAdSizeBanner) ];

  _bannerView.adUnitID = @"YOUR_AD_UNIT_ID";
  _bannerView.rootViewController = self;

  // Make the ad request.
  [_bannerView loadRequest:[GAMRequest request]];
}
```

To see an example implementation of the Ad Manager Fluid ad size,
download the iOS API Demo app in Swift or Objective-C.

[Download API Demo](https://github.com/googleads/googleads-mobile-ios-examples/releases/latest)

## GADAdSizeDelegate protocol

You may want to know the height of a banner before its ad size changes.
The `adView:willChangeAdSizeTo:` callback notifies its delegate before
the banner view changes to the new `GADAdSize`. To be notified before
the banner view changes to the new ad size, your class must conform to
the `GADAdSizeDelegate` protocol.

Here's a sample implementation of the `adView:willChangeAdSizeTo:`
callback that shows how to get the new width and height of the banner:

### Swift

```swift
// To be notified before the banner's ad size changes, your view controller class must
// conform to the GADAdSizeDelegate protocol.
bannerView.adSizeDelegate = self

// MARK: - GADAdSizeDelegate

func adView(_ bannerView: BannerView, willChangeAdSizeTo adSize: AdSize) {
  let height = adSize.size.height
  let width = adSize.size.width
}
```

### Objective-C

    // To be notified before the banner's ad size changes, your view controller class must
    // conform to the GADAdSizeDelegate protocol.
    _bannerView.adSizeDelegate = self;

    #pragma mark - GADAdSizeDelegate

    - (void)adView:(GADBannerView *)bannerView willChangeAdSizeTo:(GADAdSize)adSize {
      CGFloat height = adSize.size.height;
      CGFloat width = adSize.size.width;
    }