Apply shader effects to views
mainEffects can be applied using two methods:
- Convenience Modifiers: Many effects have direct wrappers (e.g.,
.foil(),.glitter()). - Generic Shader Modifier: Use
.shader(_ effect: ShaderEffect, tilt: CGPoint? = nil, time: TimeInterval? = nil)for effects without wrappers.
Important Rules:
- Stacking Order: Effects wrap the view they are attached to. The order of modifiers determines the visual stack (chain order = stack order).
- Layering: You can attach effects to specific sub-views to create a 'split-layer' effect where only certain parts of the card are shaded.
- Manual Context: If you are using shaders outside of a
HolographicCardContainer, you must manually inject context using.shaderContext(tilt:time:touchPosition:).
CardContent()
.foil(intensity: 0.8)
.glitter()
.lightSweep()