템플릿을 사용하여 레이아웃 설정
표준 레이아웃 템플릿을 사용할 수 있습니다. 템플릿에는 모든 시각적 광고 자산에 대한 사전 구성된 설정이 포함되어 있지만 사용자 정의할 수 있습니다.
코드 예시
let bannerView = NativeBannerView()
bannerView.ad = ad
view.addSubview(bannerView)
let appearance = MutableNativeTemplateAppearance.default()
let orangeColor = UIColor(red: 1, green: 176.0/255, blue: 32.0/255, alpha: 1)
let blueColor = UIColor(red: 0, green: 170.0/255, blue: 1, alpha: 1)
appearance.borderColor = orangeColor
let ratingAppearance = appearance.ratingAppearance?.mutableCopy() as? MutableRatingAppearance
ratingAppearance?.filledStarColor = orangeColor
appearance.ratingAppearance = ratingAppearance
let callToActionTextAppearance = LabelAppearance(font: .systemFont(ofSize: 14), textColor: blueColor)
let callToActionAppearance = ButtonAppearance(
textAppearance: callToActionTextAppearance,
normalColor: .clear,
highlightedColor: .gray,
borderColor: blueColor,
borderWidth: 1
)
appearance.callToActionAppearance = callToActionAppearance
appearance.ageAppearance = LabelAppearance(font: .systemFont(ofSize: 12), textColor: .gray)
appearance.titleAppearance = LabelAppearance(font: .systemFont(ofSize: 14), textColor: .black)
appearance.bodyAppearance = LabelAppearance(font: .systemFont(ofSize: 12), textColor: .gray)
let imageConstraint = SizeConstraint(type: .fixed, value: 60)
appearance.imageAppearance = ImageAppearance(widthConstraint: imageConstraint)
bannerView.apply(appearance)
Примечание
자신만의 템플릿 기반 디자인을 만들 때 모든 시각적 요소에 대해 선호하는 설정을 할 필요는 없습니다. 선호하는 설정이 없는 요소는 기본값으로 구성됩니다.
Was the article helpful?
Previous
Next