PulseSymbolEffect
A type that fades the opacity of some or all layers in a symbol-based image.
Declaration
struct PulseSymbolEffectOverview
A pulse animation applies an opacity ramp to the layers in a symbol. You can choose to animate only layers marked as “always-pulses” or all layers simultaneously. Participating layers reduce their opacity to a minimum value before returning to fully opaque.
// Add an effect in SwiftUI.
@State private var value1 = 0
@State private var value2 = 0
var body: some View {
HStack {
Image(systemName: "person.text.rectangle")
// Pulse only layers marked as "always-pulse."
.symbolEffect(.pulse, value: value1)
.onTapGesture {
value1 += 1
}
Image(systemName: "person.text.rectangle")
// Pulse all layers three times simultaneously.
.symbolEffect(.pulse.wholeSymbol, options: .repeat(3), value: value2)
.onTapGesture {
value2 += 1
}
}
}// Add an effect in AppKit and UIKit.
// Pulse only layers marked as "always-pulse."
imageView1.addSymbolEffect(.pulse.byLayer, options: .nonRepeating)
// Pulse all layers three times simultaneously.
imageView2.addSymbolEffect(.pulse.wholeSymbol, options: .repeat(3))