スマートバナー
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
プラットフォームを選択:
Android
iOS
Unity
スマートバナーは、あらゆる画面サイズのデバイスで、画面をどの向きにしていても横幅いっぱいに広告を表示できる広告ユニットです。デバイスの向きに応じて画面の横幅が検知され、そのサイズの広告ビューが作成されます。
iPhone 向けのスマートバナーの縦向きの高さは 50 ポイント、横向きの高さは 32 ポイントです。iPad では、縦と横の高さは 90 ポイントです。
イメージ広告の大きさが割り当てられたスペース全体に満たない場合は、画像が中央寄せになり、両側のスペースが塗りつぶされます。

スマートバナーを使用するには、広告サイズとして kGADAdSizeSmartBannerPortrait
(縦向きの場合)か kGADAdSizeSmartBannerLandscape
(横向きの場合)を指定します。
Swift
let bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
Objective-C
GADBannerView *bannerView = [[GADBannerView alloc]
initWithAdSize:kGADAdSizeSmartBannerPortrait];
iOS 11 ではセーフエリアが増えたため、全幅表示のバナーについては、バナーの端をセーフエリアの端に合わせる制限も加えてください。その具体的な方法を示すコード スニペットは次のとおりです。
Swift
func addBannerViewToView(_ bannerView: GADBannerView) {
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
if #available(iOS 11.0, *) {
// In iOS 11, we need to constrain the view to the safe area.
positionBannerViewFullWidthAtBottomOfSafeArea(bannerView)
}
else {
// In lower iOS versions, safe area is not available so we use
// bottom layout guide and view edges.
positionBannerViewFullWidthAtBottomOfView(bannerView)
}
}
// MARK: - view positioning
@available (iOS 11, *)
func positionBannerViewFullWidthAtBottomOfSafeArea(_ bannerView: UIView) {
// Position the banner. Stick it to the bottom of the Safe Area.
// Make it constrained to the edges of the safe area.
let guide = view.safeAreaLayoutGuide
NSLayoutConstraint.activate([
guide.leftAnchor.constraint(equalTo: bannerView.leftAnchor),
guide.rightAnchor.constraint(equalTo: bannerView.rightAnchor),
guide.bottomAnchor.constraint(equalTo: bannerView.bottomAnchor)
])
}
func positionBannerViewFullWidthAtBottomOfView(_ bannerView: UIView) {
view.addConstraint(NSLayoutConstraint(item: bannerView,
attribute: .leading,
relatedBy: .equal,
toItem: view,
attribute: .leading,
multiplier: 1,
constant: 0))
view.addConstraint(NSLayoutConstraint(item: bannerView,
attribute: .trailing,
relatedBy: .equal,
toItem: view,
attribute: .trailing,
multiplier: 1,
constant: 0))
view.addConstraint(NSLayoutConstraint(item: bannerView,
attribute: .bottom,
relatedBy: .equal,
toItem: bottomLayoutGuide,
attribute: .top,
multiplier: 1,
constant: 0))
}
Objective-C
- (void)addBannerViewToView:(UIView *)bannerView {
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:bannerView];
if (@available(ios 11.0, *)) {
// In iOS 11, we need to constrain the view to the safe area.
[self positionBannerViewFullWidthAtBottomOfSafeArea:bannerView];
} else {
// In lower iOS versions, safe area is not available so we use
// bottom layout guide and view edges.
[self positionBannerViewFullWidthAtBottomOfView:bannerView];
}
}
#pragma mark - view positioning
- (void)positionBannerViewFullWidthAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {
// Position the banner. Stick it to the bottom of the Safe Area.
// Make it constrained to the edges of the safe area.
UILayoutGuide *guide = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[guide.leftAnchor constraintEqualToAnchor:bannerView.leftAnchor],
[guide.rightAnchor constraintEqualToAnchor:bannerView.rightAnchor],
[guide.bottomAnchor constraintEqualToAnchor:bannerView.bottomAnchor]
]];
}
- (void)positionBannerViewFullWidthAtBottomOfView:(UIView *_Nonnull)bannerView {
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeLeading
multiplier:1
constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTrailing
multiplier:1
constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.bottomLayoutGuide
attribute:NSLayoutAttributeTop
multiplier:1
constant:0]];
}
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-31 UTC。
[null,null,["最終更新日 2025-08-31 UTC。"],[[["\u003cp\u003eSmart Banners are responsive ad units that adjust their size to fit the width of the device's screen, spanning the full width in either portrait or landscape orientation.\u003c/p\u003e\n"],["\u003cp\u003eOn iPhones, Smart Banners have a height of 50 points in portrait and 32 points in landscape; on iPads, the height is consistently 90 points in both orientations.\u003c/p\u003e\n"],["\u003cp\u003eIt is recommended to use the newer adaptive banners instead of Smart Banners for better ad performance and user experience.\u003c/p\u003e\n"],["\u003cp\u003eFor full-width banners, especially with iOS 11 and later, constraints should be added to align the banner edges with the safe area edges for optimal display.\u003c/p\u003e\n"]]],[],null,["# Smart Banners\n\nSelect platform: [Android](/admob/android/banner/smart \"View this page for the Android platform docs.\") [iOS](/admob/ios/banner/smart \"View this page for the iOS platform docs.\") [Unity](/admob/unity/banner/smart \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\n| Try the newer [adaptive banners](/admob/ios/banner/anchored-adaptive) instead.\n\nSmart Banners are ad units that render screen-width banner ads on any screen\nsize across different devices in either orientation. Smart Banners detect the\nwidth of the device in its current orientation and create the ad view that size.\n\nSmart Banners on iPhones have a height of 50 points in portrait and 32 points in\nlandscape. On iPads, height is 90 points in both portrait and landscape.\n\nWhen an image ad isn't large enough to take up the entire allotted space, the\nimage will be centered, and the space on either side will be filled in.\n\nTo use Smart Banners, just specify `kGADAdSizeSmartBannerPortrait`\n(for portait orientation) or `kGADAdSizeSmartBannerLandscape` (for landscape\norientation) for the ad size: \n\n### Swift\n\n```swift\nlet bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)\n```\n\n### Objective-C\n\n```objective-c\nGADBannerView *bannerView = [[GADBannerView alloc]\n initWithAdSize:kGADAdSizeSmartBannerPortrait];\n```\n\nSince the addition of the safe area for iOS 11, for full-width banners you\nshould also add constraints for the edges of the banner to the edges of the\nsafe area. Here is a code snippet showing how to do this: \n\n### Swift\n\n```swift\nfunc addBannerViewToView(_ bannerView: GADBannerView) {\n bannerView.translatesAutoresizingMaskIntoConstraints = false\n view.addSubview(bannerView)\n if #available(iOS 11.0, *) {\n // In iOS 11, we need to constrain the view to the safe area.\n positionBannerViewFullWidthAtBottomOfSafeArea(bannerView)\n }\n else {\n // In lower iOS versions, safe area is not available so we use\n // bottom layout guide and view edges.\n positionBannerViewFullWidthAtBottomOfView(bannerView)\n }\n}\n\n// MARK: - view positioning\n@available (iOS 11, *)\nfunc positionBannerViewFullWidthAtBottomOfSafeArea(_ bannerView: UIView) {\n // Position the banner. Stick it to the bottom of the Safe Area.\n // Make it constrained to the edges of the safe area.\n let guide = view.safeAreaLayoutGuide\n NSLayoutConstraint.activate([\n guide.leftAnchor.constraint(equalTo: bannerView.leftAnchor),\n guide.rightAnchor.constraint(equalTo: bannerView.rightAnchor),\n guide.bottomAnchor.constraint(equalTo: bannerView.bottomAnchor)\n ])\n}\n\nfunc positionBannerViewFullWidthAtBottomOfView(_ bannerView: UIView) {\n view.addConstraint(NSLayoutConstraint(item: bannerView,\n attribute: .leading,\n relatedBy: .equal,\n toItem: view,\n attribute: .leading,\n multiplier: 1,\n constant: 0))\n view.addConstraint(NSLayoutConstraint(item: bannerView,\n attribute: .trailing,\n relatedBy: .equal,\n toItem: view,\n attribute: .trailing,\n multiplier: 1,\n constant: 0))\n view.addConstraint(NSLayoutConstraint(item: bannerView,\n attribute: .bottom,\n relatedBy: .equal,\n toItem: bottomLayoutGuide,\n attribute: .top,\n multiplier: 1,\n constant: 0))\n}\n```\n\n### Objective-C\n\n```objective-c\n- (void)addBannerViewToView:(UIView *)bannerView {\n bannerView.translatesAutoresizingMaskIntoConstraints = NO;\n [self.view addSubview:bannerView];\n if (@available(ios 11.0, *)) {\n // In iOS 11, we need to constrain the view to the safe area.\n [self positionBannerViewFullWidthAtBottomOfSafeArea:bannerView];\n } else {\n // In lower iOS versions, safe area is not available so we use\n // bottom layout guide and view edges.\n [self positionBannerViewFullWidthAtBottomOfView:bannerView];\n }\n}\n\n#pragma mark - view positioning\n\n- (void)positionBannerViewFullWidthAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {\n // Position the banner. Stick it to the bottom of the Safe Area.\n // Make it constrained to the edges of the safe area.\n UILayoutGuide *guide = self.view.safeAreaLayoutGuide;\n\n [NSLayoutConstraint activateConstraints:@[\n [guide.leftAnchor constraintEqualToAnchor:bannerView.leftAnchor],\n [guide.rightAnchor constraintEqualToAnchor:bannerView.rightAnchor],\n [guide.bottomAnchor constraintEqualToAnchor:bannerView.bottomAnchor]\n ]];\n}\n\n- (void)positionBannerViewFullWidthAtBottomOfView:(UIView *_Nonnull)bannerView {\n [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView\n attribute:NSLayoutAttributeLeading\n relatedBy:NSLayoutRelationEqual\n toItem:self.view\n attribute:NSLayoutAttributeLeading\n multiplier:1\n constant:0]];\n [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView\n attribute:NSLayoutAttributeTrailing\n relatedBy:NSLayoutRelationEqual\n toItem:self.view\n attribute:NSLayoutAttributeTrailing\n multiplier:1\n constant:0]];\n [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView\n attribute:NSLayoutAttributeBottom\n relatedBy:NSLayoutRelationEqual\n toItem:self.bottomLayoutGuide\n attribute:NSLayoutAttributeTop\n multiplier:1\n constant:0]];\n}\n```"]]