AEPButton
The AEPButton class is a fundamental UI component used to create interactive buttons for content cards.
Customization of the button's properties can be achieved with a custom view modifier.
AEPButton conforms to ObservableObject
, allowing it to be used reactively in SwiftUI views.
Public Properties
Property | Type | Description |
---|---|---|
text | The text model representing the button's label. | |
modifier | AEPViewModifier | A custom view modifier that can be applied to the button view for additional styling. |
All properties are marked with @Published. Any changes will trigger updates to the UI.
Customization
You can customize the AEPButton
properties when working with a template that includes a button. Here's an example:
Swift
Copied to your clipboardclass MyCustomizer: ContentCardCustomizing {func customize(template: SmallImageTemplate) {// Customize the button elementtemplate.buttons?.first?.text.font = .headlinetemplate.buttons?.first?.text.textColor = .whitetemplate.buttons?.first?.modifier = AEPViewModifier(MyButtonModifier())}struct MyButtonModifier: ViewModifier {func body(content: Content) -> some View {content.padding().background(Color.blue).cornerRadius(10)}}}