고정 크기 배너 광고

플랫폼 선택: Android iOS Flutter

Google 모바일 광고 SDK는 적응형 배너 광고가 필요에 맞지 않는 상황에서 고정 광고 크기를 지원합니다.

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

크기(dp)(폭x높이) 설명 사용 가능 여부 AdSize 상수
320x50 배너 휴대전화 및 태블릿 GADAdSizeBanner
320x100 대형 배너 휴대전화 및 태블릿 GADAdSizeLargeBanner
300x250 IAB 중간 직사각형 휴대전화 및 태블릿 GADAdSizeMediumRectangle
468x60 IAB 전체 크기 배너 태블릿 GADAdSizeFullBanner
728x90 IAB 리더보드 태블릿 GADAdSizeLeaderboard

맞춤 배너 크기를 정의하려면 GADAdSizeFromCGSize를 사용하여 크기를 설정하세요.

Swift

let adSize = adSizeFor(cgSize: 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 = adSizeFor(cgSize: 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. 앱의 GAMBannerView에서 validAdSizes 속성을 설정합니다.

    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(AdSizeBanner),
        NSValueFromGADAdSize(AdSizeMediumRectangle),
        NSValueFromGADAdSize(adSizeFor(cgSize: 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: BannerView, willChangeAdSizeTo size: AdSize)
    

    Objective-C

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

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

    Swift

    bannerView.adSizeDelegate = self
    

    Objective-C

    self.bannerView.adSizeDelegate = self;
    

여러 광고 크기 예

Swift Objective-C