# Implement banner ads in iOS

> Implement banner ads in your iOS app. Create and display banner view objects within your view hierarchy, and use a delegate to manage ad events.

> **Important:**
>
> [app-ads.txt](/monetization/dashboard/app-ads-txt.md) is an [IAB](https://www.iab.com/) initiative to combat fraud and create transparency in the advertising ecosystem. Ensure that you implement app-ads.txt as described. Otherwise, banner demand might significantly decrease.

You can place the banner view object into your view hierarchy, just like you would any other view. This allows you to customize the position of each banner instance, or display multiple banners.

> **Note:**
>
> Banner content will not render outside of the Safe Area, as described in [Apple's guidelines](https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area).

## Script implementation

The following script sample is an example implementation for displaying two banner ads on the screen. For more information on the classes referenced, refer to the `UADSBannerAd` API section.

### Implementing the MREC banner format

> **Note:**
>
> You must [initialize](/ads-android/4.19.0/sdk-integration/initialize-sdk.md) Unity Ads before displaying a banner ad.

To display a medium rectangle (MREC) sized ad format in your app, ensure the proper dimensions are used, such as 300x250, 300x300, or 450x450. In the case of a 300x250 MREC banner ad specifically, replace this in the following example code:

```objective-c
CGSizeMake(320, 50)
```

With this adjusted dimension:

```objective-c
CGSizeMake(300, 250)
```

#### Banner ad load example

1. **Objective-C**

   ```objective-c
   @interface MyDelegate : NSObject <UADSBannerAdDelegate>
   @end

   @implementation MyDelegate
   - (void)bannerImpression:(UADSBannerAd *)banner {
   }
   - (void)bannerDidClick:(UADSBannerAd *)banner {
   }
   - (void)bannerDidFailShow:(UADSBannerAd *)banner
                   error:(id<UnityAdsError>)error {
   }
   @end

   @property (strong) UADSBannerAd *bannerAd;

   UADSBannerLoadConfigurationBuilder *builder =
   [[UADSBannerLoadConfigurationBuilder alloc]
   initWithPlacementId:placementId
               bannerSize:CGSizeMake(320, 50)
               delegate:delegate];
   builder = [builder withMediationInfo:self.mediationInfo];
   builder = [builder withAdMarkup:bidResponse];

   [UADSBannerAd load:[builder build]
       completion:^(UADSBannerAd *ad, id<UnityAdsError> error) {
   if (!error) {
       self.bannerAd = ad;
       [container addSubview:ad.view];
   }
   }];
   ```

2. **Swift**

   ```swift
   class MyDelegate: NSObject, UADSBannerAdDelegate {
   func bannerImpression(_ banner: UADSBannerAd) {
   }

   func bannerDidClick(_ banner: UADSBannerAd) {
   }

   func bannerDidFailShow(
      _ banner: UADSBannerAd,
      error: UnityAdsError
   ) {
    }
   }

   var bannerAd: UADSBannerAd?

   let config = UADSBannerLoadConfigurationBuilder(
   placementId: placementId,
   bannerSize: CGSize(width: 320, height: 50),
   delegate: delegate
   )
   .with(mediationInfo: mediationInfo)
   .with(adMarkup: bidResponse)
   .build()

   UADSBannerAd.load(config) { ad, error in
   if let ad = ad {
         self.bannerAd = ad
         container.addSubview(ad.view)
       }
   }
   ```

**Next steps**: Review the [monetization strategy](/monetization/getting-started/monetization-strategy.md) guide and [test your implementation](/ads-ios/4.19.0/sdk-integration/test-integration.md).
