네이티브 스타일 설정을 사용하면
Google Ad Manager에서 제품 내에 지정한 네이티브 스타일을 기반으로 네이티브 광고의 렌더링을
처리할 수 있습니다. 먼저 크기 및 타겟팅을 지정합니다.
그런 다음 HTML, CSS, JavaScript를 추가하여 반응형 광고를 정의하고
모든 화면에서 고화질로 표시되는 광고를 생성합니다. 렌더링을 직접
할 필요가 없습니다. Ad Manager에서 도착 페이지에 맞는 네이티브 스타일을
자동으로 적용합니다. 네이티브 스타일은 GAMBannerView를 사용하여 배너 광고와 마찬가지로
구현됩니다. 사전에 결정된 고정 광고
크기 또는 런타임에 결정된 유동 광고 크기와 함께 사용할 수 있습니다.
기본 요건
Google 모바일 광고 SDK 버전 7.14.0 이상
이 가이드는 Google 모바일 광고 SDK에 대한 실무적인 이해가 있다는 것을 전제로 설명을 제공합니다.
시작하기 가이드를 진행하지 않은 경우 시작하기 가이드부터
진행하시기 바랍니다.
고정 크기
고정 크기의 네이티브 스타일을 사용하면 네이티브 광고의
너비와 높이를 설정할 수 있습니다. 고정 크기를 설정하려면 다음 단계를 따르세요.
Ad Manager UI에서 광고 항목을 만들고 Size 필드 드롭다운에서 사전 정의된
크기 중 하나를 선택합니다.
Interface Builder에서 GAMBannerView의 너비와 높이를 1단계에서 선택한 사전 정의된 크기와 일치하도록 설정합니다. 배너 크기
섹션에서 크기 목록과
해당 GADAdSize 상수를
확인할 수 있습니다.
고정 크기의 네이티브 스타일을 구현하는 것은
첫 번째 배너
요청의 안내를 따르는 것만큼 간단하지만,
HTML, CSS, JavaScript를 유연하게 제어하여
앱에서 자연스러운 네이티브 디자인과 느낌을 배너 광고에 부여할 수 있습니다.
유동 크기
경우에 따라 고정 크기가 적합하지 않을 수 있습니다. 예를 들어 광고의 너비는
앱의 콘텐츠와 일치해야 하지만 높이는 광고의 콘텐츠에 맞게
동적으로 조정해야 할 수 있습니다. 이 경우를 처리하려면
Ad Manager UI에서 광고 크기를 Fluid로 지정하면 됩니다. 이렇게 하면
앱에서 런타임에 광고 크기를 지정합니다.
SDK는 이 경우를 처리하기 위해
특수 GADAdSize 상수인 kGADAdSizeFluid를
제공합니다. 유동 광고 크기 높이는
게시자가 정의한 너비를 기반으로 하여 동적으로 결정되므로
GAMBannerView가
광고 소재의 높이에 맞게 높이를 조정할 수 있습니다.
유동 요청
다른 광고 형식과 달리 kGADAdSizeFluid 광고 크기에는
사전 정의된 너비가 없으므로 코드나 인터페이스 빌더에서 배너의 프레임 너비를
명시적으로 설정해야 합니다. 너비를 지정하지 않으면
SDK는 기본적으로 기기의 전체 너비를 기반으로
배너의 높이를 설정합니다.
kGADAdSizeFluid가 포함된 다중 크기 요청을 하면
반환된 광고가 항상 유동 컨테이너 내에 배치되고
유동 광고처럼 작동합니다. 이 유동 컨테이너에 유동이 아닌 광고 소재가 반환되는 경우
새 광고가 반환될 때마다
너비 제약 조건을 수정하지 않아도 되도록
SDK가 컨테이너에서 광고를 중앙에 배치합니다.
단일 크기 및 다중 크기 유동형 요청을 만드는 구현은
매우 유사합니다. 유일한 차이점은 다중 크기 요청의 경우
validAdSizes 속성을 설정하여 광고 요청에
유효한 광고 크기를 지정한다는 것입니다.
varbannerView:AdManagerBannerView!overridefuncviewDidLoad(){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)varframeRect=bannerView.frameframeRect.size.width=view.bounds.widthbannerView.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
GAMBannerView*_bannerView;-(void)viewDidLoad{[superviewDidLoad];// 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=[[GAMBannerViewalloc]initWithAdSize:kGADAdSizeFluid];CGRectframeRect=_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.[_bannerViewloadRequest:[GAMRequestrequest]];}
Ad Manager 유동 광고 크기의 구현 예를 확인하려면
Swift 또는 Objective-C로 작성된 iOS API 데모 앱을 다운로드하세요.
광고 크기가 변경되기 전에 배너의 높이를 알아야 할 수 있습니다.
adView:willChangeAdSizeTo: 콜백은 배너 뷰가 새 GADAdSize로 변경되기 전에
대리자에게 알립니다. 배너 뷰가 새 광고 크기로 변경되기 전에
알림을 받으려면 클래스가 GADAdSizeDelegate 프로토콜을
준수해야 합니다.
다음은 배너의 새 너비와 높이를 가져오는 방법을 보여주는
adView:willChangeAdSizeTo: 콜백의 샘플 구현입니다.
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: - GADAdSizeDelegatefuncadView(_bannerView:BannerView,willChangeAdSizeToadSize:AdSize){letheight=adSize.size.heightletwidth=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;
#pragmamark-GADAdSizeDelegate-(void)adView:(GADBannerView*)bannerViewwillChangeAdSizeTo:(GADAdSize)adSize{CGFloatheight=adSize.size.height;CGFloatwidth=adSize.size.width;}
[null,null,["최종 업데이트: 2025-08-25(UTC)"],[[["\u003cp\u003eNative Styles in Google Ad Manager allow you to customize the look and feel of native ads using HTML, CSS, and JavaScript, rendering them seamlessly within your app.\u003c/p\u003e\n"],["\u003cp\u003eYou can define fixed-size native ads by specifying their dimensions in Ad Manager and your app's layout, similar to implementing banner ads.\u003c/p\u003e\n"],["\u003cp\u003eFluid-size native ads adjust their height dynamically based on content and available width, requiring you to set the desired width in your app's code.\u003c/p\u003e\n"],["\u003cp\u003eTo get notified before a banner's size changes (especially useful for fluid ads), implement the \u003ccode\u003eGADAdSizeDelegate\u003c/code\u003e protocol and its \u003ccode\u003eadView:willChangeAdSizeTo:\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eYou can download the iOS API Demo app for example implementations of Native Styles, including fluid ad sizes.\u003c/p\u003e\n"]]],["Native styles in Google Ad Manager utilize HTML, CSS, and JavaScript for ad rendering. Ad size can be fixed by setting predefined dimensions in the UI and `GAMBannerView`, or fluid, adjusting dynamically at runtime with `kGADAdSizeFluid`. Fluid ads require setting the banner's frame width. Multisize requests can include fluid and other ad sizes. `GADAdSizeDelegate` enables notification before banner size changes, providing access to the new width and height.\n"],null,["# Native Styles\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/native/styles \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/native/styles \"View this page for the iOS platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/native/styles \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\n| **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](/ad-manager/mobile-ads-sdk/ios/native/advanced).\n\n[Native style settings](//support.google.com/admanager/answer/6366914)\nenable Google Ad Manager to handle the rendering of your native ads based on native\nstyles you specify within the product. First, specify size and targeting.\nThen add HTML, CSS, and JavaScript to define ads that are responsive\nand produce a quality display across all screens. You don't need to do\nany of the rendering; Ad Manager automatically applies the right native style\nfor the destination. Native styles are implemented just like banner ads,\nusing a `GAMBannerView`. They can be used with a fixed ad\nsize determined ahead of time, or a fluid ad size determined at runtime.\n\nPrerequisites\n-------------\n\n- Google Mobile Ads SDK version 7.14.0 or higher\n\nThis guide assumes some working knowledge of the Google Mobile Ads SDK.\nIf you haven't already done so, consider running through our\n[Get Started](/ad-manager/mobile-ads-sdk/ios/quick-start) guide.\n\nFixed size\n----------\n\nNative styles with a fixed size allow you to control the width and height\nof the native ad. To set a fixed size, follow these steps:\n\n1. Create a line item in the Ad Manager UI and select one of the\n predefined sizes from the `Size` field dropdown.\n\n2. In Interface Builder, set the width and height of the `GAMBannerView`\n to match the predefined size you selected in step 1. You can see a\n list of sizes and their corresponding `GADAdSize` constants in the [Banner\n size](/ad-manager/mobile-ads-sdk/ios/banner#banner_size)\n section.\n\nImplementing native styles with a fixed size is as simple as following\nthe instructions in [Your first banner\nrequest](/ad-manager/mobile-ads-sdk/ios/quick-start#your_first_banner_request),\nbut you gain the flexibility and control over the HTML, CSS, and JavaScript\nto give your banner ad a native look and feel that's natural in your app.\n\nFluid size\n----------\n\nIn some cases, a fixed size may not make sense. For example, you may\nwant the width of the ad to match your app's content, but need its height\nto dynamically adjust to fit the ad's content. To handle this case,\nyou can specify `Fluid` as the ad size in the Ad Manager UI, which\ndesignates that the size of the ad is determined at runtime in the app.\nThe SDK provides a special `GADAdSize` constant,\n[`kGADAdSizeFluid`](/ad-manager/mobile-ads-sdk/ios/api/reference/Constants#/c:@kGADAdSizeFluid),\nto handle this case. The fluid ad size height is dynamically determined\nbased on the publisher defined width, allowing the\n[`GAMBannerView`](/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GAMBannerView),\nto adjust its height to match that of the creative.\n\n### Fluid request\n\nUnlike other ad formats, the `kGADAdSizeFluid` ad size does not have\na predefined width, so make sure to explicitly set the banner's frame\nwidth in your code or in Interface Builder. If a width is not specified,\nthe SDK by default sets the height of the banner based on the full\nwidth of the device.\n\nIf you make a multisize request that includes `kGADAdSizeFluid`,\nthe ad returned is always placed inside a fluid container and\nbehave like a fluid ad. In the event that a non-fluid creative is\nreturned in this fluid container, the SDK centers the ad in the\ncontainer so that you don't have to modify the width constraint\neach time a new ad is returned.\n\nThe implementation for making a single size and a multisize fluid\nrequest is very similar; the only difference is for a multisize\nrequest, you set the `validAdSizes` property to specify the ad\nsizes that are valid for the ad request: \n\n### Swift\n\n bannerView.validAdSizes = [nsValue(for: AdSizeFluid), nsValue(for: AdSizeBanner)]\n\n### Objective-C\n\n _bannerView.validAdSizes = @[ NSValueFromGADAdSize(kGADAdSizeFluid),\n NSValueFromGADAdSize(kGADAdSizeBanner) ];\n\nHere's what the full implementation looks like in code: \n\n### Swift\n\n var bannerView: AdManagerBannerView!\n\n override func viewDidLoad() {\n super.viewDidLoad()\n // Create the GAMBannerView and set its width to a width that makes sense for your\n // app. In this example, the width is set to the width of the UIViewController's\n // root view.\n bannerView = AdManagerBannerView(adSize: AdSizeFluid)\n var frameRect = bannerView.frame\n frameRect.size.width = view.bounds.width\n bannerView.frame = frameRect\n\n // Uncomment this code for a multisize fluid request.\n // bannerView.validAdSizes = [nsValue(for: AdSizeFluid), nsValue(for: AdSizeBanner)]\n\n bannerView.adUnitID = \"YOUR_AD_UNIT_ID\"\n bannerView.rootViewController = self\n\n // Make the ad request.\n bannerView.load(AdManagerRequest())\n }\n\n### Objective-C\n\n GAMBannerView *_bannerView;\n\n - (void)viewDidLoad {\n [super viewDidLoad];\n // Create the GAMBannerView and set its width to a width that makes sense for your\n // app. In this example, the width is set to the width of the UIViewController's\n // root view.\n _bannerView = [[GAMBannerView alloc] initWithAdSize:kGADAdSizeFluid];\n CGRect frameRect = _bannerView.frame;\n frameRect.size.width = CGRectGetWidth(self.view.bounds);\n _bannerView.frame = frameRect;\n\n // Uncomment this code for a multisize fluid request.\n // _bannerView.validAdSizes = @[ NSValueFromGADAdSize(kGADAdSizeFluid),\n // NSValueFromGADAdSize(kGADAdSizeBanner) ];\n\n _bannerView.adUnitID = @\"YOUR_AD_UNIT_ID\";\n _bannerView.rootViewController = self;\n\n // Make the ad request.\n [_bannerView loadRequest:[GAMRequest request]];\n }\n\nTo see an example implementation of the Ad Manager Fluid ad size,\ndownload the iOS API Demo app in Swift or Objective-C.\n\n[Download API Demo](//github.com/googleads/googleads-mobile-ios-examples/releases/latest)\n\nGADAdSizeDelegate protocol\n--------------------------\n\nYou may want to know the height of a banner before its ad size changes.\nThe `adView:willChangeAdSizeTo:` callback notifies its delegate before\nthe banner view changes to the new `GADAdSize`. To be notified before\nthe banner view changes to the new ad size, your class must conform to\nthe `GADAdSizeDelegate` protocol.\n\nHere's a sample implementation of the `adView:willChangeAdSizeTo:`\ncallback that shows how to get the new width and height of the banner: \n\n### Swift\n\n // To be notified before the banner's ad size changes, your view controller class must\n // conform to the GADAdSizeDelegate protocol.\n bannerView.adSizeDelegate = self\n\n // MARK: - GADAdSizeDelegate\n\n func adView(_ bannerView: BannerView, willChangeAdSizeTo adSize: AdSize) {\n let height = adSize.size.height\n let width = adSize.size.width\n }\n\n### Objective-C\n\n // To be notified before the banner's ad size changes, your view controller class must\n // conform to the GADAdSizeDelegate protocol.\n _bannerView.adSizeDelegate = self;\n\n #pragma mark - GADAdSizeDelegate\n\n - (void)adView:(GADBannerView *)bannerView willChangeAdSizeTo:(GADAdSize)adSize {\n CGFloat height = adSize.size.height;\n CGFloat width = adSize.size.width;\n }"]]