ネイティブ テンプレート
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ネイティブ テンプレートのダウンロード
ネイティブ広告を使用すると、広告をカスタマイズして、質の高いユーザー エクスペリエンスを提供することができます。ユーザー エクスペリエンスが向上すると、エンゲージメントが促進され、全体的な収益の拡大にもつながります。
ネイティブ広告を最大限に活かすには、広告レイアウトがアプリの他の部分に自然に馴染むようなスタイルにすることが重要です。初めての方向けに、ネイティブ テンプレートが用意されています。
ネイティブ テンプレートとは、ネイティブ広告として使用できるビューであり、コーディングが完成された状態で提供されるため、実装と変更を簡単に行えます。初めてのネイティブ広告を数分で実装でき、大量のコードに煩わされることなく短時間でデザインをカスタマイズできます。このテンプレートは、ニュース フィード内で使用する TableView やダイアログなど、アプリ内のどこにでも好きな場所に配置できます。
このガイドでは、iOS アプリにネイティブ テンプレートをダウンロードして追加、使用する方法について説明します。このガイドは、すでに SDK を使用してネイティブ広告を読み込んでいる方を対象としています。
テンプレートのサイズ
テンプレートのサイズには、小と中の 2 種類があります。それぞれのテンプレートは、GADTSmallTemplateView
クラスと GADTMediumTemplateView
クラスで表されます。どちらのクラスも GADTTemplateView
を拡張します。どちらのテンプレートもアスペクト比が固定されており、addHorizontalConstraintsToSuperviewWidth
を呼び出した場合にのみ、親ビューの幅に合うようにサイズが調整されます。addHorizontalConstraintsToSuperviewWidth
を呼び出さない場合、各テンプレートはデフォルトのサイズで表示されます。
GADTSmallTemplateView
小サイズのテンプレートは、UICollectionView
や UITableView
のセルに最適です。たとえば、インフィード広告など、細長い形の広告ビューが必要な場所で使用できます。このテンプレートのデフォルトのサイズは、高さ 91 ポイント、幅 355 ポイントです。

GADTMediumTemplateView
中サイズのテンプレートは、ページビューの大きさの 1/2~3/4 に相当します。ランディング ページやスプラッシュ ページに適していますが、UITableViews
に含めることもできます。このテンプレートのデフォルトのサイズは、高さ 370 ポイント、幅 355 ポイントです。

どのテンプレートでも自動レイアウトがサポートされていますので、プレースメントを自由にお試しください。必要に応じて、ソースコードと xib ファイルを変更することもできます。
ネイティブ広告テンプレートをインストールする
ネイティブ広告テンプレートをインストールするには、その zip をダウンロードして XCode プロジェクトにドラッグします。その際は、[Copy items if needed] チェックボックスがオンになっていることを確認してください。

ネイティブ広告テンプレートを使用する
プロジェクトにフォルダを追加して、関連するクラスをファイルに含めたら、次の要領でテンプレートを使用してください。なお、フォントとスタイルのプロパティを変更するには、必ずスタイル ディクショナリをご使用ください。現在のところ、xib 自体に設定されたスタイルはすべてオーバーライドされます。
Objective-C
/// Step 1: Import the templates that you need.
#import "NativeTemplates/GADTSmallTemplateView.h"
#import "NativeTemplates/GADTTemplateView.h"
...
// STEP 2: Initialize your template view object.
GADTSmallTemplateView *templateView =
[[NSBundle mainBundle] loadNibNamed:@"GADTSmallTemplateView" owner:nil options:nil]
.firstObject;
// STEP 3: Template views are just GADNativeAdViews.
_nativeAdView = templateView;
nativeAd.delegate = self;
// STEP 4: Add your template as a subview of whichever view you'd like.
// This must be done before calling addHorizontalConstraintsToSuperviewWidth.
// Please note: Our template objects are subclasses of GADNativeAdView so
// you can insert them into whatever type of view you’d like, and don’t need to
// create your own.
[self.view addSubview:templateView];
// STEP 5 (Optional): Create your styles dictionary. Set your styles dictionary
// on the template property. A default dictionary is created for you if you do
// not set this. Note - templates do not currently respect style changes in the
// xib.
NSString *myBlueColor = @"#5C84F0";
NSDictionary *styles = @{
GADTNativeTemplateStyleKeyCallToActionFont : [UIFont systemFontOfSize:15.0],
GADTNativeTemplateStyleKeyCallToActionFontColor : UIColor.whiteColor,
GADTNativeTemplateStyleKeyCallToActionBackgroundColor :
[GADTTemplateView colorFromHexString:myBlueColor],
GADTNativeTemplateStyleKeySecondaryFont : [UIFont systemFontOfSize:15.0],
GADTNativeTemplateStyleKeySecondaryFontColor : UIColor.grayColor,
GADTNativeTemplateStyleKeySecondaryBackgroundColor : UIColor.whiteColor,
GADTNativeTemplateStyleKeyPrimaryFont : [UIFont systemFontOfSize:15.0],
GADTNativeTemplateStyleKeyPrimaryFontColor : UIColor.blackColor,
GADTNativeTemplateStyleKeyPrimaryBackgroundColor : UIColor.whiteColor,
GADTNativeTemplateStyleKeyTertiaryFont : [UIFont systemFontOfSize:15.0],
GADTNativeTemplateStyleKeyTertiaryFontColor : UIColor.grayColor,
GADTNativeTemplateStyleKeyTertiaryBackgroundColor : UIColor.whiteColor,
GADTNativeTemplateStyleKeyMainBackgroundColor : UIColor.whiteColor,
GADTNativeTemplateStyleKeyCornerRadius : [NSNumber numberWithFloat:7.0],
};
templateView.styles = styles;
// STEP 6: Set the ad for your template to render.
templateView.nativeAd = nativeAd;
// STEP 7 (Optional): If you'd like your template view to span the width of your
// superview call this method.
[templateView addHorizontalConstraintsToSuperviewWidth];
[templateView addVerticalCenterConstraintToSuperview];
スタイル ディクショナリ キー
次のキーを使ってディクショナリを作成すると、テンプレートをすばやくカスタマイズできます。
Objective-C
/// Call to action font. Expects a UIFont.
GADTNativeTemplateStyleKeyCallToActionFont
/// Call to action font color. Expects a UIColor.
GADTNativeTemplateStyleKeyCallToActionFontColor;
/// Call to action background color. Expects a UIColor.
GADTNativeTemplateStyleKeyCallToActionBackgroundColor;
/// The font, font color and background color for the first row of text in the
/// template.
/// All templates have a primary text area which is populated by the native ad's
/// headline.
/// Primary text font. Expects a UIFont.
GADTNativeTemplateStyleKeyPrimaryFont;
/// Primary text font color. Expects a UIFont.
GADTNativeTemplateStyleKeyPrimaryFontColor;
/// Primary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeyPrimaryBackgroundColor;
/// The font, font color and background color for the second row of text in the
/// template.
/// All templates have a secondary text area which is populated either by the
/// body of the ad, or by the rating of the app.
/// Secondary text font. Expects a UIFont.
GADTNativeTemplateStyleKeySecondaryFont;
/// Secondary text font color. Expects a UIColor.
GADTNativeTemplateStyleKeySecondaryFontColor;
/// Secondary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeySecondaryBackgroundColor;
/// The font, font color and background color for the third row of text in the
/// template. The third row is used to display store name or the default
/// tertiary text.
/// Tertiary text font. Expects a UIFont.
GADTNativeTemplateStyleKeyTertiaryFont;
/// Tertiary text font color. Expects a UIColor.
GADTNativeTemplateStyleKeyTertiaryFontColor;
/// Tertiary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeyTertiaryBackgroundColor;
/// The background color for the bulk of the ad. Expects a UIColor.
GADTNativeTemplateStyleKeyMainBackgroundColor;
/// The corner rounding radius for the icon view and call to action. Expects an
/// NSNumber.
GADTNativeTemplateStyleKeyCornerRadius;
よくある質問
- テンプレートのオブジェクトをインスタンス化しようとすると、例外が発生するのはなぜですか?
- xib ファイルでビューのサイズを変更しても、サブクラスの「setup」メソッドで作成したフレームのサイズを変更していないと、この例外が発生します。
- これらのテンプレートをさらにカスタマイズするにはどうすればよいですか?
- これらのテンプレートは、iOS アプリの開発で使用可能な他の xib やカスタムのビュークラスと同様に、関連付けられたビューのオブジェクトを含む xib にすぎません。ネイティブ広告を一から作成する場合は、ネイティブ アドバンス ガイドをご覧ください。
- xib でスタイルを設定しても、スタイルが更新されません。なぜですか?
- 現在のところ、xib のすべてのスタイルは、
GADTTemplateView.m
のデフォルトのスタイル ディクショナリによってオーバーライドされます。
投稿する
ネイティブ広告を簡単に開発できるようにネイティブ テンプレートを作成しました。
ぜひ皆様も新しいテンプレートや機能を GitHub レポジトリに投稿してください。プルリクエストを送っていただければ確認いたします。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[[["\u003cp\u003eNative Templates provide pre-built ad views for faster native ad implementation and easier customization in iOS apps.\u003c/p\u003e\n"],["\u003cp\u003eThese templates come in two sizes, small and medium, suitable for various ad placements within your app.\u003c/p\u003e\n"],["\u003cp\u003eCustomize the templates' appearance by using a style dictionary to modify fonts, colors, and background elements.\u003c/p\u003e\n"],["\u003cp\u003eDownload the templates from GitHub, integrate them into your project, and populate them with your native ad content.\u003c/p\u003e\n"],["\u003cp\u003eFurther customize or build native ads from scratch by referring to the Native Advanced documentation and the templates' source code.\u003c/p\u003e\n"]]],["Native Templates offer pre-built views for implementing native ads in iOS apps, customizable for a seamless user experience. Download templates from GitHub and integrate them into Xcode. There are two sizes available: `GADTSmallTemplateView` (in-feed) and `GADTMediumTemplateView` (splash pages), both scalable. Customize templates by creating a style dictionary with keys for fonts, colors, and background, then set template styles and the ad before rendering. You can modify the source code or contribute to the GitHub repository.\n"],null,["# Native Templates\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/native/templates \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/native/templates \"View this page for the iOS platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/native/templates \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\n[Download Native Templates](//github.com/googleads/googleads-mobile-ios-native-templates)\n| **Key Point:** Before continuing, know how to [load a native\n| ad](/ad-manager/mobile-ads-sdk/ios/native#load-ad).\n\n\nUsing native ads you can customize your ads resulting in a better user\nexperience. Better user experiences can increase engagement and improve your\noverall yield.\n\nIn order to get the most out of native ads, it's important to style your ad\nlayouts so that they feel like a natural extension of your app. To help you get\nstarted, we've created Native Templates.\n\nNative Templates are code-complete views for your native ads, designed for fast\nimplementation and easy modification. With Native Templates, you can implement\nyour first native ad in just a few minutes, and you can quickly customize the\nlook and feel without a lot of code. You can place these templates anywhere you\nwant, such as in a TableView used in a news feed, in a dialog, or anywhere else\nin your app.\n| **Note:** If you're interested in designing your own native layouts from scratch, return to the [Native Advanced](/ad-manager/mobile-ads-sdk/ios/native/advanced) documentation instead.\n\nThis guide will show you how to download, include, and use Native Templates in\nyour iOS apps. It assumes you've already successfully used the SDK to load a\nnative ad.\n\nTemplate sizes\n--------------\n\nThere are two template sizes: small and medium. Each template is represented\nby a class. The classes are `GADTSmallTemplateView` and\n`GADTMediumTemplateView`. Both classes extend `GADTTemplateView`. Both\ntemplates have a fixed aspect ratio, which will scale to fill the width of\ntheir parent views only if you call `addHorizontalConstraintsToSuperviewWidth`.\nIf you don't call `addHorizontalConstraintsToSuperviewWidth`, each template\nwill render its default size.\n\n### GADTSmallTemplateView\n\nThe small template is ideal for `UICollectionView` or `UITableView` cells. For\ninstance you could use it for in-feed ads, or anywhere you need a thin\nrectangular ad view. The default size of this template is 91 points high by 355\npoints wide.\n\n### GADTMediumTemplateView\n\nThe medium template is meant to be a 1/2 to 3/4-page view. This is good for\nlanding or splash pages, but can also be included in `UITableViews`. The\ndefault size of this template is 370 points high by 355 points wide.\n\nAll of our templates support autolayout, so feel free to experiment with\nplacement. Of course, you can also change the source code and xib files to\nsuit your requirements.\n\nInstalling the native ad templates\n----------------------------------\n\nTo install the Native Templates, simply download the zip and drag it into your\nXcode project. Make sure you check **Copy items if needed**.\n\nUsing the native ad templates\n-----------------------------\n\nOnce you've added the folder to your project and included the relevant class in\nyour file, follow this recipe to use a template. Note that the only way\nto change font and style properties is using the styles dictionary---we\ncurrently override any style set in the xib itself.\n\n### Objective-C\n\n```python\n/// Step 1: Import the templates that you need.\n#import \"NativeTemplates/GADTSmallTemplateView.h\"\n#import \"NativeTemplates/GADTTemplateView.h\"\n...\n\n// STEP 2: Initialize your template view object.\nGADTSmallTemplateView *templateView =\n [[NSBundle mainBundle] loadNibNamed:@\"GADTSmallTemplateView\" owner:nil options:nil]\n .firstObject;\n\n// STEP 3: Template views are just GADNativeAdViews.\n_nativeAdView = templateView;\nnativeAd.delegate = self;\n\n// STEP 4: Add your template as a subview of whichever view you'd like.\n// This must be done before calling addHorizontalConstraintsToSuperviewWidth.\n// Please note: Our template objects are subclasses of GADNativeAdView so\n// you can insert them into whatever type of view you'd like, and don't need to\n// create your own.\n[self.view addSubview:templateView];\n\n// STEP 5 (Optional): Create your styles dictionary. Set your styles dictionary\n// on the template property. A default dictionary is created for you if you do\n// not set this. Note - templates do not currently respect style changes in the\n// xib.\n\nNSString *myBlueColor = @\"#5C84F0\";\nNSDictionary *styles = @{\n GADTNativeTemplateStyleKeyCallToActionFont : [UIFont systemFontOfSize:15.0],\n GADTNativeTemplateStyleKeyCallToActionFontColor : UIColor.whiteColor,\n GADTNativeTemplateStyleKeyCallToActionBackgroundColor :\n [GADTTemplateView colorFromHexString:myBlueColor],\n GADTNativeTemplateStyleKeySecondaryFont : [UIFont systemFontOfSize:15.0],\n GADTNativeTemplateStyleKeySecondaryFontColor : UIColor.grayColor,\n GADTNativeTemplateStyleKeySecondaryBackgroundColor : UIColor.whiteColor,\n GADTNativeTemplateStyleKeyPrimaryFont : [UIFont systemFontOfSize:15.0],\n GADTNativeTemplateStyleKeyPrimaryFontColor : UIColor.blackColor,\n GADTNativeTemplateStyleKeyPrimaryBackgroundColor : UIColor.whiteColor,\n GADTNativeTemplateStyleKeyTertiaryFont : [UIFont systemFontOfSize:15.0],\n GADTNativeTemplateStyleKeyTertiaryFontColor : UIColor.grayColor,\n GADTNativeTemplateStyleKeyTertiaryBackgroundColor : UIColor.whiteColor,\n GADTNativeTemplateStyleKeyMainBackgroundColor : UIColor.whiteColor,\n GADTNativeTemplateStyleKeyCornerRadius : [NSNumber numberWithFloat:7.0],\n};\n\ntemplateView.styles = styles;\n\n// STEP 6: Set the ad for your template to render.\ntemplateView.nativeAd = nativeAd;\n\n// STEP 7 (Optional): If you'd like your template view to span the width of your\n// superview call this method.\n[templateView addHorizontalConstraintsToSuperviewWidth];\n[templateView addVerticalCenterConstraintToSuperview];\n```\n\nStyle dictionary keys\n---------------------\n\nThe fastest way to customize your templates is to make a dictionary with the\nfollowing keys:\n\n### Objective-C\n\n```scilab\n/// Call to action font. Expects a UIFont.\nGADTNativeTemplateStyleKeyCallToActionFont\n\n/// Call to action font color. Expects a UIColor.\nGADTNativeTemplateStyleKeyCallToActionFontColor;\n\n/// Call to action background color. Expects a UIColor.\nGADTNativeTemplateStyleKeyCallToActionBackgroundColor;\n\n/// The font, font color and background color for the first row of text in the\n/// template.\n\n/// All templates have a primary text area which is populated by the native ad's\n/// headline.\n\n/// Primary text font. Expects a UIFont.\nGADTNativeTemplateStyleKeyPrimaryFont;\n\n/// Primary text font color. Expects a UIFont.\nGADTNativeTemplateStyleKeyPrimaryFontColor;\n\n/// Primary text background color. Expects a UIColor.\nGADTNativeTemplateStyleKeyPrimaryBackgroundColor;\n\n/// The font, font color and background color for the second row of text in the\n/// template.\n\n/// All templates have a secondary text area which is populated either by the\n/// body of the ad, or by the rating of the app.\n\n/// Secondary text font. Expects a UIFont.\nGADTNativeTemplateStyleKeySecondaryFont;\n\n/// Secondary text font color. Expects a UIColor.\nGADTNativeTemplateStyleKeySecondaryFontColor;\n\n/// Secondary text background color. Expects a UIColor.\nGADTNativeTemplateStyleKeySecondaryBackgroundColor;\n\n/// The font, font color and background color for the third row of text in the\n/// template. The third row is used to display store name or the default\n/// tertiary text.\n\n/// Tertiary text font. Expects a UIFont.\nGADTNativeTemplateStyleKeyTertiaryFont;\n\n/// Tertiary text font color. Expects a UIColor.\nGADTNativeTemplateStyleKeyTertiaryFontColor;\n\n/// Tertiary text background color. Expects a UIColor.\nGADTNativeTemplateStyleKeyTertiaryBackgroundColor;\n\n/// The background color for the bulk of the ad. Expects a UIColor.\nGADTNativeTemplateStyleKeyMainBackgroundColor;\n\n/// The corner rounding radius for the icon view and call to action. Expects an\n/// NSNumber.\nGADTNativeTemplateStyleKeyCornerRadius;\n```\n\nFAQs\n----\n\nWhy do I get an exception when I try to instantiate the template object?\n: This can happen if you've changed the size of the view in the xib file but\n haven't changed the size of the frame created in the \"setup\" method of the\n subclass.\n\nHow can I further customize these templates?\n: These templates are just xibs with associated view objects, like any other\n xib and custom view class you may be used to from iOS development.\n If you prefer to build your native ads from scratch, see our\n [Native Advanced guide](/ad-manager/mobile-ads-sdk/ios/native/advanced).\n\nWhy aren't my styles updating when I set them in the xib?\n: We currently override all xib styles by the default styles dictionary in\n `GADTTemplateView.m`.\n\nContribute\n----------\n\nWe've made Native Templates to help you develop native ads quickly.\nWe'd love to see you contribute to our\n[GitHub](//github.com/googleads/googleads-mobile-ios-native-templates)\nrepo to add new templates or features. Send us a pull request and we'll take a\nlook."]]