Post

Replies

Boosts

Views

Activity

Reply to SwiftUI anchorPreference .leading misbehaving?
This isn't an answer, but the comment field won't allow code blocks or image attachments. My initial assumption that .leading was being treated as .left doesn't appear to be correct. If you position a circle at the anchor point using the following changes to ConentView it completely off of the blue rectangle for right-to-left layout. struct ContentView: View { var body: some View { HStack(spacing: 0) { Color.green Color.blue .anchorPreference(key: AnchorPreferenceKey.self, value: .leading, transform: { $0 }) } .overlayPreferenceValue(AnchorPreferenceKey.self) { anchor in GeometryReader { proxy in let leading: CGPoint = proxy[anchor!] Circle() .fill(Color.red) .frame(width: 16, height: 16) .position(leading) } } } }
Mar ’22
Reply to @available(iOS 15.0, *) causes runtime crash on iOS 14.7 device
According to this answer on the Swift forums the ability to apply @available conditions to properties at all is a bug in Swift that has been fixed on the main branch, so it sounds like this code won't compile at all in future versions of Swift. https://forums.swift.org/t/why-is-available-property-wrapper-allowed-but-stored-property-isnt/56459/2 It's actually a bug fixed on the main branch. Conditionally-available property wrappers are not allowed for the same reason as conditionally-available stored properties.
Apr ’22