gernot, German
@gernot@mas.to avatar

Question: I am using AnchorPreferences. Is there any way to use multiple AnchorPreferences at once? Like, use an array of points and communicating it up the hierarchy, but using a collection of [Anchor<CGPoint>] instead of the single Anchor<CGPoint> that the .anchorPreference modifier hands over?

ctietze,
@ctietze@mastodon.social avatar

@gernot I believe you can create your own "preference" to bubble up the array of values, and then extract these elsewhere to use as anchor points.

Provided that AnchorPreferences doesn't do secret magic, of which I'm not 100% certain (as with anything SwiftUI)

gernot,
@gernot@mas.to avatar

@ctietze This is what I am doing. Essentially the whole „Anchor“ thing is just a fancy way of bubbling up geometry values in the „global“ CoordinateSpace, and it’s converted back at the point of use. I can do the whole ting myself by „convention“ thtat the points I use are global, but I’d rather do it with Apples wrapper that makes it explicit – if I can.

ctietze,
@ctietze@mastodon.social avatar

@gernot https://developer.apple.com/documentation/swiftui/preferences# The Preference API looks just like anchorPreference(...) -- but without the "anchor" in the name. You could create your overloads where Value is Array<Anchor<CGPoint>>

  • All
  • Subscribed
  • Moderated
  • Favorites
  • SwiftUI
  • DreamBathrooms
  • ngwrru68w68
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • tacticalgear
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • ethstaker
  • megavids
  • GTA5RPClips
  • modclub
  • tester
  • anitta
  • osvaldo12
  • cisconetworking
  • everett
  • cubers
  • Leos
  • provamag3
  • normalnudes
  • JUstTest
  • lostlight
  • All magazines