Posts

Post not yet marked as solved
0 Replies
795 Views
I would like to create an animation that repeats forever and depends on a random variable. Something like the following:import SwiftUI struct ContentView: View { @State var resize = 100 var repeatingAnimation : Animation { return Animation.default.repeatForever() } var body: some View { VStack { Spacer() RoundedRectangle(cornerRadius: 10) .frame(width: 40, height: CGFloat(resize)) .onAppear() { withAnimation(self.repeatingAnimation) { self.resize = Int.random(in: 100 ... 400) } } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }However the random in line 17 is only executed on initial load/appear. I was hoping that "resize" would change every time the animation repeats, so that the height of the RoundedRectangle would fluctuate/change.How can this be done?Kind regards,Anders Sejersbøl
Posted
by sejersbol.
Last updated
.
Post marked as solved
2 Replies
1.3k Views
Hi,I'm trying to make a simple Master-Detail SwiftUI app, like the one you can choose when you create a new project in Xcode, with the only exception that the first row in the table/List is pushed initially (at first app load). I.e. when the app starts I want the detail view for the first row to be shown. Then, when you navigate back, you will see the table/List. How can this be done? (iPhone, not iPad with split view.)I have tried setting the isActive argument of NavigationLink to true for the first row only, and this looks like it has the wanted effect. However, when you navigate back, from the detail view of the first row (after having set isActive to false again), it is not possible to push the first row again (bug?).Any idea of how this can be done?Kind regards,Anders Sejersbøl.
Posted
by sejersbol.
Last updated
.