AEPText
The AEPText class is a fundamental UI component used to display text for content cards.
This class allows you to customize the text element with properties like font, color, and modifier.
AEPText class conforms to ObservableObject
, allowing it to be used reactively in SwiftUI views.
Properties
Property | Type | Description | Default Value |
---|---|---|---|
content | String | The actual text content to be displayed. | N/A |
font | The font to be used for the text. | Depends on the type of text:
| |
color | The color of the text. | ||
modifier | AEPViewModifier | A custom view modifer that can be applied to the text view for additional styling | N/A |
All properties are marked with @Published. Any changes will trigger updates to your UI.
Customization
Below is an example of how to customize the AEPText
properties when working with a SmallImageTemplate
:
Copied to your clipboardclass MyCustomizer : ContentCardCustomizing {func customize(template: SmallImageTemplate) {// Customize the title text elementtemplate.title.font = .subheadlinetemplate.title.textColor = .greentemplate.title.modifier = AEPViewModifier(MyTitleModifier())// Customize the body text element, if availabletemplate.body?.font = .caption}struct MyTitleModifier: ViewModifier {func body(content: Content) -> some View {content.padding().background(Color.yellow).cornerRadius(5)}}}