---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://boost.yandex.com/doc/en/ad-monetization/dev/ios/template.md
  - https://boost.yandex.com/doc/ru/ad-monetization/dev/ios/template.md
  - https://boost.yandex.com/doc/zh/ad-monetization/dev/ios/template.md
  - href: https://boost.yandex.com/doc/zh/ad-monetization/dev/ios/template.md
    type: text/markdown
    title: Markdown version
  - href: https://boost.yandex.com/doc/zh/llms.txt?revision=r21772739
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/zh/llms.txt?revision=r21772739

# 使用模板设置布局

 

您可以使用标准布局模板：该模板包括所有视觉广告资产的预配置设置，但可以进行自定义。

{% cut "代码示例" %}

```swift
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)

```

{% endcut %}

{% note info %}

创建您自己的基于模板的设计时，您不必为所有视觉元素进行首选设置。任何没有首选设置的元素都使用默认值进行配置。

{% endnote %}
