78 lines
2.7 KiB
Swift
78 lines
2.7 KiB
Swift
//
|
|
// SeismicNetworkAdvertiseTableViewCell.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Andrea Busi on 20/02/21.
|
|
// Copyright © 2021 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import GoogleMobileAds
|
|
|
|
|
|
class SeismicNetworkAdvertiseTableViewCell: UITableViewCell {
|
|
|
|
static let Identifier = "SeismicNetworkAdvertiseTableViewCell"
|
|
|
|
private lazy var containerView: UIView = {
|
|
let view = UIView(frame: .zero)
|
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
view.layer.cornerRadius = AppTheme.shared.cardCornerRadius
|
|
view.layer.masksToBounds = false
|
|
|
|
// add shadow
|
|
view.layer.shadowColor = UIColor.black.cgColor
|
|
view.layer.shadowOpacity = 0.5
|
|
view.layer.shadowOffset = CGSize(width: 0, height: 2)
|
|
view.layer.shadowRadius = 2
|
|
return view
|
|
}()
|
|
|
|
private lazy var bannerView: GADNativeAdView = {
|
|
let view = GADTMediumTemplateView()
|
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
return view
|
|
}()
|
|
|
|
// MARK: - Init
|
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
setupUI()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
super.init(coder: coder)
|
|
setupUI()
|
|
}
|
|
|
|
// MARK - Private
|
|
|
|
private func setupUI() {
|
|
selectionStyle = .default
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
backgroundColor = .clear
|
|
|
|
// container view
|
|
contentView.addSubview(containerView)
|
|
containerView.backgroundColor = .red
|
|
containerView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 4.0).isActive = true
|
|
containerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -8.0).isActive = true
|
|
containerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8.0).isActive = true
|
|
containerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -4.0).isActive = true
|
|
containerView.heightAnchor.constraint(equalToConstant: 350.0).isActive = true
|
|
|
|
containerView.addSubview(bannerView)
|
|
bannerView.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
|
|
bannerView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
|
|
bannerView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true
|
|
bannerView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
|
|
}
|
|
|
|
// MARK: - Public
|
|
|
|
func loadNativeAd(_ nativeAd: GADNativeAd) {
|
|
bannerView.nativeAd = nativeAd
|
|
}
|
|
}
|