Posts

Post marked as solved
1 Replies
996 Views
In the following sample, tapping the 'Expand' button causes the text '39' to clip as it resizes in transition to '40'. I'd like for the text to only take up the space that it requires, but without clipping as it animates between values.Disabling animations for the label isn't an option, as the real use case here involves the animation of other modifiers to the view (e.g. offset).import SwiftUI struct TextClipping: View { @State var expanded = false var body: some View { VStack(spacing: 16) { Text(expanded ? "40" : "39") .font(.title) .foregroundColor(.blue) Button(action: { withAnimation { self.expanded.toggle() } }, label: { Text(expanded ? "Contract" : "Expand") .animation(nil) // Not an option for text above }) } } } struct TextClipping_Previews: PreviewProvider { static var previews: some View { TextClipping() } }Any ideas for how I might allow the text of the label to change fluidly, without clipping?[Filed as FB7383199]
Posted
by mpangburn.
Last updated
.
Post not yet marked as solved
0 Replies
202 Views
A layout question:If I have an arbitrary CGPoint and a View (whose size may be dynamic)—what's the easiest way to ensure that the View's center always aligns with the specific CGPoint?
Posted
by mpangburn.
Last updated
.