콘텐츠 상세 - 배너 광고 추가

This commit is contained in:
Yu Sung
2023-09-14 12:16:01 +09:00
parent 48b1093dac
commit b2f0975ad1
9 changed files with 577 additions and 66 deletions

View File

@@ -0,0 +1,33 @@
//
// BannerAdView.swift
// SodaLive
//
// Created by klaus on 2023/09/14.
//
import SwiftUI
import UIKit
import GoogleMobileAds
struct BannerAdView: UIViewControllerRepresentable {
let adUnitId: String
func makeUIViewController(context: Context) -> some UIViewController {
let viewController = UIViewController()
let bannerSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(UIScreen.main.bounds.width)
let banner = GADBannerView(adSize: bannerSize)
banner.rootViewController = viewController
viewController.view.addSubview(banner)
viewController.view.frame = CGRect(origin: .zero, size: bannerSize.size)
banner.adUnitID = adUnitId
banner.load(GADRequest())
return viewController
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}