고정 크기 배너 광고

Google 모바일 광고 SDK는 적응형 배너 광고가 광고주의 요구를 충족하지 못하는 경우에 고정 광고 크기를 지원합니다.

다음 표에는 표준 배너 크기가 나와 있습니다.

크기(dp)(WxH) 설명 지원 대상 AdSize 상수
320x50 배너 휴대전화 및 태블릿 GADAdSizeBanner
320x100 대형 배너 휴대전화 및 태블릿 GADAdSizeLargeBanner
300x250 IAB 중간 직사각형 휴대전화 및 태블릿 GADAdSizeMediumRectangle
468 x 60 IAB 원본 크기 배너 태블릿 GADAdSizeFullBanner
728x90 IAB 리더보드 태블릿 GADAdSizeLeaderboard

맞춤 배너 크기를 지정하려면 GADAdSizeFromCGSize를 사용하여 크기를 설정합니다.

Swift

let adSize = GADAdSizeFromCGSize(CGSize(width: 250, height: 250))

Objective-C

GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));

고정 크기 배너 광고의 예

Swift Objective-C

맞춤 광고 크기

Google Ad Manager를 사용하면 일반 광고 단위 외에도 크기가 조정된 광고 단위를 앱에 게재할 수 있습니다. 광고 요청에 정의된 광고 크기 (너비, 높이)는 앱에 표시되는 광고 보기 (GAMBannerView)의 크기와 일치해야 합니다. 맞춤 크기를 설정하려면 GADAdSizeFromCGSize를 사용하세요.

Swift

// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = GADAdSizeFromCGSize(CGSize(width: 250, height: 250))
bannerView = GAMBannerView(adSize: customAdSize)

Objective-C

// Define custom GADAdSize of 250x250 for GAMBannerView
GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(250, 250));
self.bannerView = [[GAMBannerView alloc] initWithAdSize:customAdSize];

다양한 광고 크기

Ad Manager를 사용하면 GAMBannerView에 게재할 수 있는 여러 광고 크기를 지정할 수 있습니다. 이 기능을 사용하려면 세 단계를 거쳐야 합니다.

  1. Ad Manager UI에서 크기가 다른 광고 소재와 연결된 광고 단위를 타겟팅하는 광고 항목을 만듭니다.

  2. 앱에서 GAMBannerViewvalidAdSizes 속성을 설정합니다.

    Swift

    // Define an optional array of GADAdSize to specify all valid sizes that are appropriate
    // for this slot. Never create your own GADAdSize directly. Use one of the
    // predefined standard ad sizes (such as GADAdSizeBanner), or create one using
    // the GADAdSizeFromCGSize method.
    //
    // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
    // that all desired sizes should be included in the validAdSizes array.
    bannerView.validAdSizes = [NSValueFromGADAdSize(GADAdSizeBanner),
        NSValueFromGADAdSize(GADAdSizeMediumRectangle),
        NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSize(width: 120, height: 20)))]
    

    Objective-C

    // Define an optional array of GADAdSize to specify all valid sizes that are appropriate
    // for this slot. Never create your own GADAdSize directly. Use one of the
    // predefined standard ad sizes (such as GADAdSizeBanner), or create one using
    // the GADAdSizeFromCGSize method.
    //
    // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
    // that all desired sizes should be included in the validAdSizes array.
    self.bannerView.validAdSizes = @[
        NSValueFromGADAdSize(GADAdSizeBanner),
        NSValueFromGADAdSize(GADAdSizeMediumRectangle),
        NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSizeMake(120, 20)))
    ];
    
  3. GADAdSizeDelegate 메서드를 구현하여 광고 크기 변경을 감지합니다.

    Swift

    public func bannerView(_ bannerView: GADBannerView, willChangeAdSizeTo size: GADAdSize)
    

    Objective-C

    - (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;
    

    광고 요청을 하기 전에 반드시 대리자를 설정해야 합니다.

    Swift

    bannerView.adSizeDelegate = self
    

    Objective-C

    self.bannerView.adSizeDelegate = self;
    

여러 광고 크기의 예

Swift Objective-C