I have several views I want to animate in concert. I plan to use keyframe animation. I want to keep the .keyFrameAnimator modifier code small; I have a lot of ...Keyframe
s inside several KeyframeTrack
s. It seems like I should be able to isolate the body of the keyframes parameter into a func or var. Builders are such a pain, I can't grok the right way to refactor their bodies out.
I've tried to make a standalone @KeyframeTrackContentBuilder<MyValue>
function but cannot figure out the right syntax/incantation to stuff it with KeyframeTrack
s.
My latest attempt is to create a func that returns a KeyframeTimeline, but that's been a deadend too.
let k: KeyframeTimeline<MyValue> = timeline(...)
CartoonCardView(color: .yellow)
.keyframeAnimator(
initialValue: k.value(time: 0)
) { content, value in
content
.rotationEffect(value.angle)
.scaleEffect(value.scale)
.offset(value.offset)
} keyframes: { _ in k }
The error on k
in the last line is "No exact matches in call to static method 'buildExpression'" with the sub-error "Candidate requires that 'KeyframeTimeline<MyValue>' conform to 'KeyframeTrackContent' (requirement specified as 'K' : 'KeyframeTrackContent') (SwiftUICore.KeyframesBuilder)"